]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 29 May 2017 16:21:42 +0000 (18:21 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 21 Aug 2020 16:50:09 +0000 (18:50 +0200)
- implemented UniversalNodeLocatorFactory + imported it
- imported Registerable
- imported NullPointerException
- imported BaseIpV4ConnectionHelper
- basically finished getUnlPort() and parse methods
- basically finished DefaultPeerPool lookup loop
- more debugging + getRequestInstance()
- added missing namespaces
- added getUnlPort()

Signed-off-by: Roland Häder <roland@mxchange.org>
57 files changed:
application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php
application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php
application/hub/classes/factories/class_
application/hub/classes/factories/discovery/class_SocketDiscoveryFactory.php
application/hub/classes/factories/locator/.htaccess [new file with mode: 0644]
application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php [new file with mode: 0644]
application/hub/classes/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php
application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php
application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php
application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php
application/hub/classes/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php
application/hub/classes/filter/chat/class_ChatWelcomeTeaserFilter.php
application/hub/classes/filter/class_
application/hub/classes/filter/crawler/class_CrawlerWelcomeTeaserFilter.php
application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php
application/hub/classes/filter/cruncher/class_CruncherWelcomeTeaserFilter.php
application/hub/classes/filter/miner/class_MinerInitializationFilter.php
application/hub/classes/filter/node/class_NodeInitializationFilter.php
application/hub/classes/filter/node/class_NodeWelcomeTeaserFilter.php
application/hub/classes/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php
application/hub/classes/filter/shutdown/chat/class_ChatShutdownFilter.php
application/hub/classes/filter/shutdown/crawler/class_CrawlerShutdownFilter.php
application/hub/classes/filter/shutdown/cruncher/class_CruncherShutdownFilter.php
application/hub/classes/filter/shutdown/miner/class_MinerShutdownFilter.php
application/hub/classes/filter/shutdown/node/class_NodeShutdown
application/hub/classes/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php
application/hub/classes/filter/shutdown/node/class_NodeShutdownNodeFilter.php
application/hub/classes/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php
application/hub/classes/handler/message-types/class_BaseMessageHandler.php
application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php
application/hub/classes/handler/protocol/class_BaseProtocolHandler.php
application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php
application/hub/classes/helper/connection/ipv4/udp/class_UdpConnectionHelper.php
application/hub/classes/lists/hub/class_HubList.php
application/hub/classes/lists/recipient/class_RecipientList.php
application/hub/classes/locator/class_UniversalNodeLocator.php
application/hub/classes/pools/class_BasePool.php
application/hub/classes/pools/peer/class_DefaultPeerPool.php
application/hub/classes/producer/cruncher/work_units/class_CruncherTestUnitProducer.php
application/hub/classes/registry/socket/class_SocketRegistry.php
application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php
application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php
application/hub/classes/template/class_BaseXmlTemplateEngine.php
application/hub/config.php
application/hub/interfaces/container/socket/class_StorableSocket.php
application/hub/interfaces/locator/class_LocateableNode.php
application/hub/interfaces/pool/class_Poolable.php
application/hub/interfaces/pool/peer/class_PoolablePeer.php
core
index.php

index feb0bc4ee3e15eb4b81575860ad2c5ffc837058b..bd6de781cddc6368709cd584de9ab2b6ce1a0fc4 100644 (file)
@@ -89,7 +89,7 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov
                                $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData);
                        } catch (FrameworkException $e) {
                                // Could not find class, what ever failed
-                               $this->debugInstance($e->getMessage());
+                               $this->debugInstance(sprintf('[%s:%d]: Exception: %s,message=%s', __METHOD__, __LINE__, $e->__toString(), $e->getMessage()));
                        }
                }
        }
index 695a197fbe07d8836ef96befb43940ca7adc803f..dc1205db11f07b308a7d01f5f5eeff8c4748db69 100644 (file)
@@ -15,6 +15,7 @@ use Hub\Listener\Listenable;
 use Hub\Network\Package\NetworkPackage;
 
 // Import framework stuff
+use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Registry\Registerable;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Socket\InvalidSocketException;
@@ -146,6 +147,9 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                // Determine protocol instance
                $protocolInstance = ProtocolDiscovery::determineProtocolByPackageData($packageData);
 
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE));
+
                // Is it valid?
                assert($protocolInstance instanceof HandleableProtocol);
 
@@ -158,15 +162,15 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                // Get the listener instance
                $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData);
 
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE));
+
                // If there is no listener who wants to have that package, we simply drop it here
                if (is_null($listenerInstance)) {
                        // Abort with no resource
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } // END - if
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE));
-
                /*
                 * Now we have the listener instance, we can determine the right
                 * resource to continue. The first step is to get the attached pool
@@ -176,14 +180,14 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                $socketInstance = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType);
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance)));
 
                // Is it FALSE, the recipient isn't known to us and we have no connection to it
-               if (($socketInstance instanceof StorableSocket) || (!$socketInstance->isValidSocket()) || ($socketInstance->getLastSocketErrorCode() > 0)) {
+               if (!($socketInstance instanceof StorableSocket) || ($socketInstance->isValidSocket()) || ($socketInstance->getLastSocketErrorCode() > 0)) {
                        // Try to create a new socket resource
                        try {
                                // Possibly noisy debug message
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($protocolInstance) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
 
                                // Get a socket resource from our factory (if succeeded)
                                $socketInstance = SocketFactory::createSocketFromPackageData($packageData, $protocolInstance);
index 0dbb3ddf862087ff392498b21c21a2e6560ef36c..8d01b5494dd575625d74ca563d9082ba0db3bac2 100644 (file)
@@ -60,7 +60,5 @@ class ???Factory extends ObjectFactory {
                // Return the instance
                return $%%%Instance;
        }
-}
 
-// [EOF]
-?>
+}
index 46ce751c4fcaf4f4ea8cb67a081549e4932db669..6ae971b2fd32a43ddd32ea5527cc2009a0946b10 100644 (file)
@@ -62,7 +62,5 @@ class SocketDiscoveryFactory extends ObjectFactory {
                // Return the instance
                return $discoveryInstance;
        }
-}
 
-// [EOF]
-?>
+}
diff --git a/application/hub/classes/factories/locator/.htaccess b/application/hub/classes/factories/locator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php b/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php
new file mode 100644 (file)
index 0000000..df00afa
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+// Own namespace
+namespace Hub\Factory\Network\Locator;
+
+// Import framework stuff
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Registry\Registry;
+
+/**
+ * A factory class for LocateableNode
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UniversalNodeLocatorFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton (registry-based) LocateableNode instance
+        *
+        * @param       $unl                    UNL address
+        * @return      $unlInstance    An instance of a LocateableNode class
+        */
+       public static final function createUnlInstanceFromString ($unl) {
+               // If there is no handler?
+               if (Registry::getRegistry()->instanceExists('unl_' . $unl)) {
+                       // Get handler from registry
+                       $unlInstance = Registry::getRegistry()->getInstance('unl_' . $unl);
+               } else {
+                       // Get the handler instance
+                       $unlInstance = self::createObjectByConfiguredName('universal_node_locator_class');
+
+                       // Parse UNL string
+                       $unlInstance->parseStringAsUnl($unl);
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance('unl_' . $unl, $unlInstance);
+               }
+
+               // Return the instance
+               return $unlInstance;
+       }
+
+       /**
+        * Creates a UNL instance from given array
+        *
+        * @param       $unlData        Array with valid UNL data
+        * @return      $unlInstance    An instance of a LocateableNode class
+        */
+       public static final function createUnlInstanceFromArray (array $unlData) {
+               // No "caching" for now
+               $unlInstance = self::createObjectByConfiguredName('universal_node_locator_class', array($unlData));
+
+               // Return it
+               return $unlInstance;
+       }
+
+}
index 262f87b33caaabdb5a9043f3bdeab5b3dff2f0a7..e0272b931824bed3183fbc54405c145df0df8dbb 100644 (file)
@@ -70,7 +70,5 @@ class AptProxyWelcomeTeaserFilter extends BaseAptProxyFilter implements Filterab
                // Now output the teaser
                $proxyInstance->outputConsoleTeaser();
        }
-}
 
-// [EOF]
-?>
+}
index 21f72634f4efef24da1bae6ebfb0dbdfd531e419..11387169ac1c3f64398e0def2a38a27351b10b30 100644 (file)
@@ -69,7 +69,5 @@ class AptProxyBootstrapExtraBootstrappingFilter extends BaseAptProxyFilter imple
                // Do some extra bootstrapping steps
                $proxyInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index c230f6af003bd15f6dfd5c2941fdeb010ea7432d..626142f06df06f23d8b1062ec906819758c90fe2 100644 (file)
@@ -69,7 +69,5 @@ class ChatBootstrapExtraBootstrappingFilter extends BaseChatFilter implements Fi
                // Do some extra bootstrapping steps
                $chatInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index 41cb1bf59a9a9a786489a28cf4bf94314ec4e7de..8ab733c1e5cacadc7f0fbd08715d9d98505aeabb 100644 (file)
@@ -69,7 +69,5 @@ class CrawlerBootstrapExtraBootstrappingFilter extends BaseCrawlerFilter impleme
                // Do some extra bootstrapping steps
                $crawlerInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index 8bd9c9470fcb1d2cf5d7ec04b7cd147d2b76872c..8e3a5983d36aae091994447c114ebf79a2ee8775 100644 (file)
@@ -69,7 +69,5 @@ class CruncherBootstrapExtraBootstrappingFilter extends BaseCruncherFilter imple
                // Do some extra bootstrapping steps
                $cruncherInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index 50b2b6aa8daed70e7e8c2a2257f1471b1511c3da..b6b15d394cd9a0ec4884cb8d348109a557deb588 100644 (file)
@@ -69,7 +69,5 @@ class MinerBootstrapExtraBootstrappingFilter extends BaseMinerFilter implements
                // Do some extra bootstrapping steps
                $minerInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index d296179993bc8dc2d82d176956471649d23dc844..ba33aa41c2eca235a5e784ace809def556ddfc64 100644 (file)
@@ -72,7 +72,5 @@ class NodeBootstrapExtraBootstrappingFilter extends BaseNodeFilter implements Fi
                // Do some extra bootstrapping steps
                $nodeInstance->doBootstrapping();
        }
-}
 
-// [EOF]
-?>
+}
index fc56a95d5a551bea81f464e7a15d44ca9a564310..4b2fcbe6507768d703bf84ab06c93b4433e53cb9 100644 (file)
@@ -77,7 +77,5 @@ class NodeBootstrapGenerateNodeIdFilter extends BaseNodeFilter implements Filter
                 */
                $nodeInstance->bootstrapAcquireNodeId($requestInstance, $responseInstance);
        }
-}
 
-// [EOF]
-?>
+}
index f87c66fc24a1d898a4b73e02d55252f11fbce1b6..a32e999e2e1f039afeadffbac77a04eb4c00062c 100644 (file)
@@ -75,7 +75,5 @@ class NodeBootstrapGenerateSessionIdFilter extends BaseNodeFilter implements Fil
                 */
                $nodeInstance->bootstrapGenerateSessionId();
        }
-}
 
-// [EOF]
-?>
+}
index ced5bca0dde09373b09a9bc285b545f81ed57322..8307cd5e31c7a288fac57c090741946b09eb0325 100644 (file)
@@ -72,7 +72,5 @@ class NodeBootstrapListenerPoolFilter extends BaseNodeFilter implements Filterab
                // Now do something
                $nodeInstance->initializeListenerPool();
        }
-}
 
-// [EOF]
-?>
+}
index 2250b18b846bda3529ed15054fc1c51db197f5b5..e1f7b674d6d0f25ab97ca352f9768eb53c1190d5 100644 (file)
@@ -70,7 +70,5 @@ class ChatWelcomeTeaserFilter extends BaseChatFilter implements Filterable {
                // Now output the teaser
                $chatInstance->outputConsoleTeaser();
        }
-}
 
-// [EOF]
-?>
+}
index 0332b8470e718cee9186e6ac9074df25f6d3dcb3..ca5659676291159cec0f634aba51006f97aba111 100644 (file)
@@ -73,7 +73,5 @@ class Hub!!!???Filter extends BaseHubFilter implements Filterable {
                // Now do something
                $this->partialStub('Please implement this step.');
        }
-}
 
-// [EOF]
-?>
+}
index ef6de3b1d0e5b2348d282d2a967e8b80c1680c58..a79a21732fd2848490d5b3e67edd0becd4258b4f 100644 (file)
@@ -70,7 +70,5 @@ class CrawlerWelcomeTeaserFilter extends BaseCrawlerFilter implements Filterable
                // Now output the teaser
                $crawlerInstance->outputConsoleTeaser();
        }
-}
 
-// [EOF]
-?>
+}
index 9316ab08c06ea13eaddd511fba658bffd94461f9..d38626ec4b0a61682971b789862f375ce9cbc0ec 100644 (file)
@@ -98,7 +98,5 @@ class CruncherInitializationFilter extends BaseCruncherFilter implements Filtera
                        $this->debugBackTrace(':  cruncher mode ' . $cruncherMode . ' is invalid.');
                }
        }
-}
 
-// [EOF]
-?>
+}
index 3db78b402868fa617fa5e84cab0d86d15841598b..9385a3e1559888c64bbf4f02b1d3b4f109f78036 100644 (file)
@@ -70,7 +70,5 @@ class CruncherWelcomeTeaserFilter extends BaseCruncherFilter implements Filterab
                // Now output the teaser
                $cruncherInstance->outputConsoleTeaser();
        }
-}
 
-// [EOF]
-?>
+}
index 1c8224883c7381b65fafbb40c00903b8531aea3b..ec04df2f8bee4deb5489632a7390bb90c808d80b 100644 (file)
@@ -98,7 +98,5 @@ class MinerInitializationFilter extends BaseMinerFilter implements Filterable {
                        $this->debugBackTrace(':  miner mode ' . $minerMode . ' is invalid.');
                }
        }
-}
 
-// [EOF]
-?>
+}
index d5230f65b463cfa934648b70b4b11027173d435c..94df363281497dde0a4e8240b710b70d8aab798b 100644 (file)
@@ -78,7 +78,5 @@ class NodeInitializationFilter extends BaseNodeFilter implements Filterable {
                // Debug message
                //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-INIT-FILTER: Node ' . $nodeMode . ' has been added to registry.');
        }
-}
 
-// [EOF]
-?>
+}
index 9b33510e7ecbb077b4bf3cae7712adaa45442fdf..00659801d47fe1ab6f600168ac049288def733c5 100644 (file)
@@ -73,7 +73,5 @@ class NodeWelcomeTeaserFilter extends BaseNodeFilter implements Filterable {
                // Now output the teaser
                $nodeInstance->outputConsoleTeaser();
        }
-}
 
-// [EOF]
-?>
+}
index c21995977c3834860f5a5ebde9a911b047534c17..56e53830a14d58d6d3291a49c4db9e8b66d22b83 100644 (file)
@@ -71,7 +71,5 @@ class AptProxyShutdownFilter extends BaseAptProxyFilter implements Filterable {
                // Shutdown the apt-proxy. This should be the last line
                $proxyInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index c86a7f5fcc492dfb2c7945c87eb5c366b8bff61b..5e5be509255034ffc8bc34a00b9a5a3f9508e90e 100644 (file)
@@ -71,7 +71,5 @@ class ChatShutdownFilter extends BaseChatFilter implements Filterable {
                // Shutdown the chat. This should be the last line
                $chatInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index 93e3e5cf951ffb02cc6ecfd0d9b094f429b2320b..fa9587c02cfddbad1e71d16f0668004e2226971b 100644 (file)
@@ -71,7 +71,5 @@ class CrawlerShutdownFilter extends BaseCrawlerFilter implements Filterable {
                // Shutdown the crawler. This should be the last line
                $crawlerInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index 4ab6c409d36b9eb42e63bc48827dbfd9a079646b..e694295ad11a31866a6df3c02959425db87cb318 100644 (file)
@@ -71,7 +71,5 @@ class CruncherShutdownFilter extends BaseCruncherFilter implements Filterable {
                // Shutdown the cruncher. This should be the last line
                $cruncherInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index 7bcbe0361dec900b0b6e01443e04330fc79fbe2b..1b289d90193c8e32455e909ff7ce5eed6f6e63c8 100644 (file)
@@ -71,7 +71,5 @@ class MinerShutdownFilter extends BaseMinerFilter implements Filterable {
                // Shutdown the miner. This should be the last line
                $minerInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index e42c1c5c7e28016e6345440793ebb30dbf8ff8c2..f2ab02bddb54d39a1f7a7b4d8ef6704522457b50 100644 (file)
@@ -73,7 +73,5 @@ class HubShutdown???Filter extends BaseNodeFilter implements Filterable {
                // Now do something
                $this->partialStub('Please implement this step.');
        }
-}
 
-// [EOF]
-?>
+}
index 5abd525ffe62e6f14f2951780438826dd215b8da..4edad0cecaf909580b401f8c1686ac3c63abcd48 100644 (file)
@@ -73,7 +73,5 @@ class NodeShutdownFlushNodeListFilter extends BaseNodeFilter implements Filterab
                // Now do something
                $this->partialStub('Please implement this step.');
        }
-}
 
-// [EOF]
-?>
+}
index 5b8d5c924ed583a2022034e2037c1fd098703140..7cd5ea05ea888e96c62d76c1b397443a342f1289 100644 (file)
@@ -74,7 +74,5 @@ class NodeShutdownNodeFilter extends BaseNodeFilter implements Filterable {
                // Shutdown the node. This should be the last line
                $nodeInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index 087664187e54a7e8bd0a9dbd2b20bc32ce1fb39c..63c3303ff99f14f2896992829c0b5faed460e50f 100644 (file)
@@ -73,7 +73,5 @@ class NodeShutdownTaskHandlerFilter extends BaseNodeFilter implements Filterable
                // Shutdown the task manager and all its registered tasks
                $handlerInstance->doShutdown();
        }
-}
 
-// [EOF]
-?>
+}
index e2dee462e1b8ae985b7e6222d0f44991774532a0..4d5563741fb305d1236af038770dc54f93f9a880 100644 (file)
@@ -57,7 +57,7 @@ abstract class BaseMessageHandler extends BaseDataHandler {
                // Is the last exception not NULL?
                if ($this->getLastException() instanceof FrameworkException) {
                        // "Determine" the right status code (may differ from exception to exception)
-                       $this->debugInstance('lastException=' . $this->getLastException()->__toString() . ',message=' . $this->getLastException()->getMessage() . ' is not finished!');
+                       $this->debugInstance(sprintf('[%s:%d]: lastException=%s,message=%s is unfinished.', __METHOD__, __LINE__, $this->getLastException()->__toString(), $this->getLastException()->getMessage()));
                } // END - if
 
                // Return the status code
index 375e6773682f9212178f1ef6dc10c197b93364c2..b485f7b197bb5646366da81da233d9dc4204ecc5 100644 (file)
@@ -81,7 +81,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle
                } else {
                        // Something really horrible happened
                        // @TODO Throw an exception here instead of dying
-                       $this->debugInstance(__METHOD__ . ': ids mismatching! messageData=' . print_r($messageData, TRUE));
+                       $this->debugInstance(sprintf('[%s:%d]: ids mismatching! messageData=%s', __METHOD__, __LINE__, print_r($messageData, TRUE)));
                }
        }
 
index 3e94c30dea62a650c6cf161e08d8966cd925866c..8353fa0c996b5be2d3f9b128508057f76d328f0f 100644 (file)
@@ -85,74 +85,6 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt
                return $isValid;
        }
 
-       /**
-        * Parses the given UNL by splitting it up in its components. The UNL ...
-        *
-        * protocol://address[:port]
-        *
-        * ... becomes:
-        *
-        * array(
-        *     'protocol' => 'value',
-        *     'address'  => 'value',
-        *     'extra'    => 'port'
-        * )
-        *
-        * The value for 'extra' then must be handled by the overwriting
-        * parseUniversalNodeLocator() method of the individual protocol handler as
-        * this is protocol-specific.
-        *
-        * @param       $unl            Universal Node Locator (UNL) to "parse"
-        * @return      $unlInstance    An instance of a LocateableNode class
-        */
-       protected function parseUniversalNodeLocator ($unl) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': unl=' . $unl . ' - CALLED!');
-
-               // Make sure the UNL is valid
-               assert($this->isValidUniversalNodeLocator($unl));
-
-               /*
-                * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-(
-                * @TODO If you know why, please fix and explain it to me.
-                */
-               $unlParts = explode('://', $unl);
-
-               // Split again the last part as: address:port
-               $unlParts[1] = explode(':', $unlParts[1]);
-
-               // Now there is an almost useable array which then can be copied to the "real" array.
-               $unlData = array(
-                       LocateableNode::UNL_PART_PROTOCOL => $unlParts[0],
-                       LocateableNode::UNL_PART_ADDRESS  => $unlParts[1][0],
-                       LocateableNode::UNL_PART_EXTRA    => $unlParts[1][1]
-               );
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
-
-               // Create instance from it
-               //$unlInstance = ;
-               $this->partialStub('Please rewrite this part.');
-
-               // Return instance
-               return $unlInstance;
-       }
-
-       /**
-        * Gets an element from universalNodeLocatorData array
-        *
-        * @param       $element        Element in universalNodeLocatorData array
-        * @return      $value          Found value
-        */
-       protected final function getUniversalNodeLocatorDataElement ($element) {
-               // Is the element there?
-               assert(isset($this->universalNodeLocatorData[$element]));
-
-               // Return it
-               return $this->universalNodeLocatorData[$element];
-       }
-
        /**
         * Getter for protocol name
         *
@@ -189,8 +121,9 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt
         * @return      $address        Address part for the final UNL
         */
        public function getAddressPart () {
-               // Return it
-               return $this->getUniversalNodeLocatorDataElement(LocateableNode::UNL_PART_ADDRESS);
+               // Get UNL instance
+               $unlInstance = $this->getUniversalNodeLocatorInstance();
+               die(__METHOD__.':'.print_r($unlInstance, TRUE));
        }
 
        /**
index e00ebb10a487f4cf7ce9144035569f2eaf1d0b06..2abc2e4a4d04ce664806b05f759b871e95b66c8c 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Handler\Protocol\Network\IpV4;
 
 // Import application-specific stuff
+use Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Hub\Handler\Protocol\BaseProtocolHandler;
 use Hub\Locator\Node\LocateableNode;
 use Hub\Network\Package\NetworkPackage;
index ca374da4724618aef98989563986b58e6f29e02d..f40fb6d067fa3d01ecf317cbca8a022189a0cf4e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Hub\Helper\Connection\IpV4;
+namespace Hub\Helper\Connection\Network\IpV4;
 
 // Import application-specific stuff
 use Hub\Helper\Connection\BaseConnectionHelper;
index f73a38a531701eeffa00ff248dce052c89e81d06..50efbbaa878a42ab7435f389894264089c20de58 100644 (file)
@@ -1,12 +1,13 @@
 <?php
 // Own namespace
-namespace Hub\Helper\Connection\Tcp;
+namespace Hub\Helper\Connection\Network\IpV4\Tcp;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
 use Hub\Factory\Handler\Protocol\ProtocolHandlerFactory;
 use Hub\Factory\Socket\SocketFactory;
 use Hub\Helper\Connection\ConnectionHelper;
+use Hub\Helper\Connection\Network\IpV4\BaseIpV4ConnectionHelper;
 use Hub\Locator\Node\LocateableNode;
 use Hub\Network\Package\NetworkPackage;
 use Hub\Tools\HubTools;
@@ -94,7 +95,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
                                // @TODO Rewrite this test for UNLs
                                if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) {
                                        // No ip:port!
-                                       $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' does not contain ":". Please fix this.');
+                                       $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s does not contain ":". Please fix this.', __METHOD__, __LINE__, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
                                } // END - if
 
                                // "explode" the ip:port, so index 1 will be the port number
@@ -109,7 +110,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
                                //$unlInstance =;
                        } else {
                                // It doesn't match, we need to take care of this later
-                               $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . '!=' . $helperInstance->getConfigInstance()->getConfigEntry('external_address'));
+                               $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s!=%s', __METHOD__, __LINE__, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $helperInstance->getConfigInstance()->getConfigEntry('external_address')));
                        }
                }
 
index bad59079faad0325d2c662a2dfe4081a11dfced2..32e286320f0e000ae7b825b63fd8a6ff601c0fb1 100644 (file)
@@ -1,10 +1,11 @@
 <?php
 // Own namespace
-namespace Hub\Helper\Connection\Udp;
+namespace Hub\Helper\Connection\Network\IpV4\Udp;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
 use Hub\Helper\Connection\ConnectionHelper;
+use Hub\Helper\Connection\Network\IpV4\BaseIpV4ConnectionHelper;
 
 /**
  * A UDP connection helper class
index e11f7b8a3c08ee3f48493c9ebcb5ad2b4e948d1b..b7933d1aeeba43f1c7e080ff1443f8bb197f1dfd 100644 (file)
@@ -62,7 +62,7 @@ class HubList extends BaseList implements Listable {
         * @return      $iteratorInstance       An instance of a Iterator class
         */
        public function getListIterator () {
-               $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!');
+               $this->debugInstance(sprintf('[%s:%d]: uses the default iterator. Please call getIterator() instead!', __METHOD__, __LINE__));
        }
 
        /**
index a6de87c583d5dd9a36d2175806ca3b5f7dfeaa80..8f3a2b75f7f5313d785a106fdd5622f5a0ca26dc 100644 (file)
@@ -66,7 +66,7 @@ class RecipientList extends BaseList implements Listable, Registerable {
         * @return      $iteratorInstance       An instance of a Iterator class
         */
        public function getListIterator () {
-               $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!');
+               $this->debugInstance(sprintf('[%s:%d]: uses the default iterator. Please call getIterator() instead!', __METHOD__, __LINE__));
        }
 
        /**
index 11d47f5d46473a1e86ec12ada7b4179fe866b1b3..1a5ad11aa3fa047f1d74e058a962756c09fdcdfc 100644 (file)
@@ -6,8 +6,12 @@ namespace Hub\Locator\Node;
 use Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
 use Hub\Generic\BaseHubSystem;
 
+// Import framework stuff
+use CoreFramework\Registry\Registerable;
+
 // Import SPL stuff
 use \BadMethodCallException;
+use \InvalidArgumentException;
 
 /**
  * A class for UNLs (Universal Node Locator)
@@ -31,7 +35,7 @@ use \BadMethodCallException;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class UniversalNodeLocator extends BaseHubSystem implements LocateableNode {
+class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Registerable {
        /**
         * UNL data array
         */
@@ -45,6 +49,9 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Set regex for UNL-validation
+               $this->setRegularExpression(LocateableNode::UNL_REGEX);
        }
 
        /**
@@ -64,45 +71,6 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode {
                return $unlInstance;
        }
 
-       /**
-        * Initializes the UNL instance by givena array. If an entry is found, it
-        * will be copied, otherwise the entry is set empty.
-        *
-        * @param       $current        An array with "raw" data from the database layer for the UNL. This parameter is optional.
-        * @return      void
-        */
-       private function initUniversalNodeLocator (array $current = array()) {
-               // Init UNL array
-               $this->unlData = array();
-
-               // Copy all found entries
-               foreach (array(
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
-                               // Init entry
-                               $this->unlData[$key] = NULL;
-
-                               // Is the key found?
-                               if (isset($current[$key])) {
-                                       // The copy the entry
-                                       $this->unlData[$key] = $current[$key];
-                               } // END - if
-               } // END - foreach
-       }
-
-       /**
-        * Getter for UNL data array
-        *
-        * @return      $unlData        An array with UNL data
-        */
-       private function getUnlData () {
-               return $this->unlData;
-       }
-
        /**
         * Getter for external UNL
         *
@@ -149,4 +117,159 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode {
                return $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL];
        }
 
+       /**
+        * Some "getter" for UNL port (if supported). If not supported, NULL is
+        * being returned.
+        *
+        * @return      $unlPort Port number of UNL
+        */
+       public function getUnlPort () {
+               // Get UNL data
+               $unlData = $this->getUnlData();
+
+               // Default value is NULL
+               $unlPort = NULL;
+
+               // Is the element there?
+               if (isset($unlData[LocateableNode::UNL_PART_EXTRA])) {
+                       // Use it
+                       $unlPort = $unlData[LocateableNode::UNL_PART_EXTRA];
+               } // END - if
+
+               // Return it
+               return $unlPort;
+       }
+
+       /**
+        * Parses given UNL string as UNL array
+        *
+        * @param       $unl    UNL string
+        * @return      void
+        */
+       public function parseStringAsUnl ($unl) {
+               // Is it basically valid?
+               if (!is_string($unl)) {
+                       // Abort here
+                       throw new InvalidArgumentException(sprintf('unl[]=%s is not string.', gettype($unl)));
+               } // END - if
+
+               // Parse it
+               $this->parseUniversalNodeLocator($unl);
+       }
+
+       /**
+        * Parses the given UNL by splitting it up in its components. The UNL ...
+        *
+        * protocol://address[:port]
+        *
+        * ... becomes:
+        *
+        * array(
+        *     'protocol' => 'value',
+        *     'address'  => 'value',
+        *     'extra'    => 'port'
+        * )
+        *
+        * The value for 'extra' then must be handled by the overwriting
+        * parseUniversalNodeLocator() method of the individual protocol handler as
+        * this is protocol-specific.
+        *
+        * @param       $unl            Universal Node Locator (UNL) to "parse"
+        * @throws      InvalidArgumentException        If given UNL is not valid
+        */
+       private function parseUniversalNodeLocator ($unl) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': unl=' . $unl . ' - CALLED!');
+
+               // Make sure the UNL is valid
+               if (!$this->isValidUniversalNodeLocator($unl)) {
+                       // UNL is not valid
+                       throw new InvalidArgumentException(sprintf('unl[%s]=%s is not valid.', gettype($unl), $unl));
+               } // END - if
+
+               /*
+                * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-(
+                * @TODO If you know why, please fix and explain it to me.
+                */
+               $unlParts = explode('://', $unl);
+
+               // Split again the last part as: address:port
+               $unlParts[1] = explode(':', $unlParts[1]);
+
+               // Now there is an almost useable array which then can be copied to the "real" array.
+               $unlData = array(
+                       LocateableNode::UNL_PART_PROTOCOL => $unlParts[0],
+                       LocateableNode::UNL_PART_ADDRESS  => $unlParts[1][0],
+                       LocateableNode::UNL_PART_EXTRA    => $unlParts[1][1],
+               );
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
+
+               // Call init method
+               $this->initUniversalNodeLocator($unlData);
+       }
+
+       /**
+        * Initializes the UNL instance by givena array. If an entry is found, it
+        * will be copied, otherwise the entry is set empty.
+        *
+        * @param       $unlData        An array with "raw" data from the database layer for the UNL. This parameter is optional.
+        * @return      void
+        */
+       private function initUniversalNodeLocator (array $unlData = array()) {
+               // Init UNL array
+               $this->unlData = array();
+
+               // Copy all found entries
+               foreach (array(
+                       LocateableNode::UNL_PART_PROTOCOL,
+                       LocateableNode::UNL_PART_ADDRESS,
+                       LocateableNode::UNL_PART_EXTRA,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
+                               // Init entry
+                               $this->unlData[$key] = NULL;
+
+                               // Is the key found?
+                               if (isset($unlData[$key])) {
+                                       // The copy the entry
+                                       $this->unlData[$key] = $unlData[$key];
+                               } // END - if
+               } // END - foreach
+       }
+
+       /**
+        * Getter for UNL data array
+        *
+        * @return      $unlData        An array with UNL data
+        */
+       private function getUnlData () {
+               return $this->unlData;
+       }
+
+       /**
+        * Validates given UNL very basicly by given regular expression. You
+        * normally don't need/want to overwrite this method as this is a very basic
+        * validation only based on a regex.
+        *
+        * @param       $unl            Universal Node Locator to validate
+        * @return      $isValid        Whether the UNL is valid
+        */
+       private final function isValidUniversalNodeLocator ($unl) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': unl=' . $unl . ',regex=' . $regex . ' - CALLED!');
+
+               // Very basic regex check
+               $isValid = (preg_match($this->getRegularExpression(), $unl) === 1);
+
+               // Return result
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': isValid=' . intval($isValid) . ' - EXIT!');
+               return $isValid;
+       }
+
 }
index 837d47f468ff59ef16e5a429b6a740b89aa3065f..39aca2d9e0d1e3816998552f4fa6fc168db28cf0 100644 (file)
@@ -98,7 +98,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable {
         * @param       $list   The list identifier we should return
         * @return      $array  The requested array
         */
-       protected final function getArrayFromList ($list) {
+       public final function getArrayFromList ($list) {
                // Get the array
                $array = $this->getPoolEntriesInstance()->getArrayFromList($list);
 
index 8bcb688807e690dd2aed03debe9866128f6e0a2c..e646b71386c20c26ab84ed323bdbd6f592db2fbb 100644 (file)
@@ -16,6 +16,9 @@ use Hub\Pool\Peer\PoolablePeer;
 // Import framework stuff
 use CoreFramework\Socket\InvalidSocketException;
 
+// Import SPL stuff
+use \LogicException;
+
 /**
  * A default peer pool class
  *
@@ -218,8 +221,12 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
         * @param       $connectionType         Type of connection, can be 'incoming', 'outgoing', 'server' or default
         * @return      $socketInstance         An instance of a StorableSocket class
         * @throws      InvalidConnectionTypeException  If the provided connection type is not valid
+        * @throws      LogicException          If an expected array element is missing
         */
        public function getSocketFromPackageData (array $packageData, $connectionType = NULL) {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType));
+
                // Default is no socket
                $socketInstance = NULL;
 
@@ -227,36 +234,38 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData);
 
                // Get UNL data
-               $unlData = $handlerInstance->getUniversalNodeLocatorDataArray();
-
-               // Make sure it is a valid Universal Node Locator array (3 elements)
-               assert(isset($unlData[LocateableNode::UNL_PART_PROTOCOL]));
-               assert(isset($unlData[LocateableNode::UNL_PART_ADDRESS]));
-               assert(isset($unlData[LocateableNode::UNL_PART_PORT]));
+               $unlInstance = $handlerInstance->getUniversalNodeLocatorInstance();
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[' . LocateableNode::UNL_PART_ADDRESS . ']=' . $unlData[LocateableNode::UNL_PART_ADDRESS] . ',unlData[' . LocateableNode::UNL_PART_PORT . ']=' . $unlData[LocateableNode::UNL_PART_PORT] . ' ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...');
 
                // Default is all sockets
                $sockets = $this->getAllSockets();
 
-               // Is connection type set?
-               if ((is_string($connectionType)) && ($this->isValidConnectionType($connectionType))) {
-                       // Then get a list of this type
-                       $sockets = $this->getSocketsByConnectionType($connectionType);
-               } elseif (is_string($connectionType)) {
-                       // Is not a valid connection type!
-                       throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
-               }
-
                // Get all sockets and check them, skip the server socket
                foreach ($sockets as $socketArray) {
-                       // Is this a server socket?
-                       if ($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->equals($this->getListenerInstance()->getSocketInstance())) {
-                               // Skip 'server' sockets (local socket)
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Skipping server socket ' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource() . ' ...');
+                       // Debugging:
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray)));
+                       //* DEBUG-DIE: */ die(__METHOD__.':connectionType='.$connectionType.',socketArray='.print_r($socketArray, TRUE));
+
+                       // Is connection type set?
+                       if (!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) {
+                               // Important array element missing
+                               throw new LogicException(sprintf('socketArray[%s] is not set.', Poolable::SOCKET_ARRAY_INSTANCE));
+                       } elseif (!isset($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])) {
+                               // Important array element missing
+                               throw new LogicException(sprintf('socketArray[%s] is not set.', Poolable::SOCKET_ARRAY_CONN_TYPE));
+                       } elseif ((!empty($connectionType)) && (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->isValidConnectionType($connectionType))) {
+                               // Is not a valid connection type!
+                               throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
+                       } elseif ((!empty($connectionType)) && ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] !== $connectionType)) {
+                               // Skip unwanted sockets
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType));
                                continue;
-                       } // END - if
+                       }
+
+                       // Debug message
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: socketInstance.socketResource=%s,socketInstance.socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
 
                        // Init peer address/port
                        $peerAddress = '0.0.0.0';
@@ -268,14 +277,16 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                                $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->handleSocketError(__METHOD__, __LINE__, explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
                        } // END - if
 
-                       // Get
+                       // Debug message
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart()));
+
                        // If the "peer" IP and recipient is same, use it
-                       if ($peerAddress == $unlData[LocateableNode::UNL_PART_ADDRESS]) {
+                       if ($peerAddress == $unlInstance->getAddressPart()) {
                                // IPs match, so take the socket and quit this loop
                                $socketInstance = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE];
 
                                // Debug message
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: peerAddress=' . $peerAddress . ' matches with recipient IP address. Taking socket=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]);
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
                                break;
                        } // END - if
                } // END - foreach
index e34d5b8ba215bc9b2dd93bb15716b43e6b27f91b..2c8d8bb740883336e7597b0e66720fa5b5f952a0 100644 (file)
@@ -96,7 +96,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
                if ($wrapperInstance->isTestUnitProduced()) {
                        // Entries found
                        // @TODO Unfinished work here
-                       $this->debugInstance();
+                       $this->debugInstance(sprintf('[%s:%d]: stateInstance=%s - Unfinished!', __METHOD__, __LINE__, $stateInstance->__toString()));
 
                        // The state must be changed because ...
                        $stateInstance->someFooStateChange();
index d3de513d7859d3ce32ef456531e06a65819e6a4f..d191433c7e27fa9549b183ec62d11008d1908231 100644 (file)
@@ -328,7 +328,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                                                $infoInstance->fillWithConnectionHelperInformation($helperInstance);
                                        } else {
                                                // Not supported state!
-                                               $this->debugInstance(': Invalid state found, please report this to the developers with full debug infos.' . PHP_EOL);
+                                               $this->debugInstance(sprintf('[%s:%d]: Invalid state found, please report this to the developers with full debug infos.', __METHOD__, __LINE__));
                                        }
 
                                        // Debug message
index 9b6842d468b4f879bfc5e15fefdaa4d5102123a2..1e8afedcfab190be86f5d402d3866ec13fc0b8ff 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\Resolver\Protocol\Tcp;
 
 // Import application-specific stuff
 use Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
+use Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Hub\Helper\Node\NodeHelper;
 use Hub\Resolver\Protocol\BaseProtocolResolver;
 use Hub\Resolver\Protocol\ProtocolResolver;
@@ -93,7 +94,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv
                assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]);
 
                // Get UNL instance and handle over all data
-               $unlInstance = ObjectFactory::createObjectByConfiguredName('universal_node_locator_class', array($current));
+               $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromArray($current);
 
                // Return resolved instance
                return $unlInstance;
index 252b7c0eec7287ad2e01284ebb1f38eeb9081241..36b772a7c416413e673fb022a9dfdb22737ba13a 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\Crawler\Source\Url\UploadList;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Registry\Registerable;
 
 /**
index 22e3c52824db7e6839ca8273d3b473067489f41e..43ee5efbd81ddd2a5664950c6e621709a5ef3ca6 100644 (file)
@@ -237,7 +237,7 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine {
                // Is this null?
                if (is_null($value)) {
                        // Bah, needs fixing.
-                       $this->debugInstance('key=' . $key . ' returns NULL');
+                       $this->debugInstance(sprintf('[%s:%d]: key=%s returns NULL', __METHOD__, __LINE__, $key));
                } // END - if
 
                // Return value
index 1d015adc9897018d41a8c49e3d93f450ecf61d24..16cfc7cffc954aeca059fb4b915fbc833f95b246 100644 (file)
@@ -745,10 +745,10 @@ $cfg->setConfigEntry('recipient_list_class', 'Hub\Lists\Recipient\RecipientList'
 $cfg->setConfigEntry('package_tags_class', 'Hub\Tag\Package\PackageTags');
 
 // CFG: TCP-CONNECTION-HELPER-CLASS
-$cfg->setConfigEntry('tcp_connection_helper_class', 'TcpConnectionHelper');
+$cfg->setConfigEntry('tcp_connection_helper_class', 'Hub\Helper\Connection\Network\IpV4\Tcp\TcpConnectionHelper');
 
 // CFG: UDP-CONNECTION-HELPER-CLASS
-$cfg->setConfigEntry('udp_connection_helper_class', 'UdpConnectionHelper');
+$cfg->setConfigEntry('udp_connection_helper_class', 'Hub\Helper\Connection\Network\IpV4\Udp\UdpConnectionHelper');
 
 // CFG: HUB-COMMUNICATION-PROTOCOL-TYPE
 $cfg->setConfigEntry('hub_communication_protocol_type', 'tcp');
index 67797780d8bf434494889d0377ff9d842aa5ae78..bc02cb2b4295ab61d00cb07d9d247c247dc8415f 100644 (file)
@@ -129,21 +129,21 @@ interface StorableSocket extends FrameworkInterface {
         *
         * @return      $result         Whether the peer has been identified
         */
-       function identifySocketPeer();
+       function identifySocketPeer ();
 
        /**
         * Tries to set socket timeout option
         *
         * @return      $result         Whether the option has been set
         */
-       function setSocketTimeoutOptions();
+       function setSocketTimeoutOptions ();
 
        /**
         * Tries to enable out-of-band (OOB) data
         *
         * @return      $result         Whether OOB has been enabled
         */
-       function enableSocketOutOfBandData();
+       function enableSocketOutOfBandData ();
 
        /**
         * Getter for socket procotol field
index 6ae4a6ad55a454d7cdcc4f53fa95e2dce1beca47..39a89bd7a33742356ac82358116d38f048189d2a 100644 (file)
@@ -59,4 +59,20 @@ interface LocateableNode extends HubInterface {
         */
        function getInternalUnl ();
 
+       /**
+        * Some "getter" for UNL port (if supported). If not supported, NULL is
+        * being returned.
+        *
+        * @return      $unlPort Port number of UNL
+        */
+       function getUnlPort ();
+
+       /**
+        * Parses given UNL string as UNL array
+        *
+        * @param       $unl    UNL string
+        * @return      void
+        */
+       function parseStringAsUnl ($unl);
+
 }
index 5f764a0cfdccd98bc7eef5f237910f2951e78fc3..3277f278df6b89809055e2c738e686137709b640 100644 (file)
@@ -32,6 +32,14 @@ interface Poolable extends HubInterface {
        const SOCKET_ARRAY_INSTANCE  = 'instance';
        const SOCKET_ARRAY_CONN_TYPE = 'connection_type';
 
+       /**
+        * Gets the array from specified list
+        *
+        * @param       $list   The list identifier we should return
+        * @return      $array  The requested array
+        */
+       function getArrayFromList ($list);
+
        /**
         * Getter for pool entries instance
         *
index 6414010a4106ccd5d52f50021587fab2d09815fb..02f73672c24abdaad5c24ade322599ca3a56404f 100644 (file)
@@ -36,22 +36,21 @@ interface PoolablePeer extends Poolable, SocketTag {
         * @param       $socketInstance         An instance of a StorableSocket class
         * @param       $connectionType         Type of connection, can only be 'incoming', 'outgoing' or 'server'
         * @return      void
-        * @throws      InvalidSocketException  If the given resource is invalid or errorous
         * @throws      InvalidConnectionTypeException  If the provided connection type is not valid
         */
        function addPeer (StorableSocket $socketInstance, $connectionType);
 
        /**
-        * Getter for array of all socket resource arrays
+        * Getter for array of all socket resources
         *
-        * @return      $sockets        An array with all socket arrays
+        * @return      $sockets        An array with all sockets
         */
        function getAllSockets ();
 
        /**
-        * Getter for array of all socket resources
+        * Getter for array of all socket arrays
         *
-        * @return      $sockets        An array with all sockets
+        * @return      $sockets        An array with all socket arrays
         */
        function getAllSingleSockets ();
 
@@ -60,7 +59,7 @@ interface PoolablePeer extends Poolable, SocketTag {
         *
         * @param       $connectionType         Type of connection, can only be 'incoming', 'outgoing' or 'server'
         * @return      $sockets                        An array with sockets of given type
-        * @throws      InvalidConnectionTypeException  If the provided connection type is not valid
+        * @throws      InvalidConnectionTypeException  If the found connection type is not valid
         */
        function getSocketsByConnectionType ($connectionType);
 
diff --git a/core b/core
index ba6776b5d9b04fd6916224c088cabf255643c6d7..fd5598626e163040b19bf8e153d4898a49038b23 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit ba6776b5d9b04fd6916224c088cabf255643c6d7
+Subproject commit fd5598626e163040b19bf8e153d4898a49038b23
index 61d5347327fde61f06cd9ded6066776cb11dd523..753e54afef0c09cffd916413bb5bc1b00a937ca9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -91,7 +91,7 @@ final class ApplicationEntryPoint {
                $templateInstance = NULL;
 
                // Get response instance
-               $responseInstance = ApplicationHelper::getSelfInstance()->getResponseInstance();
+               $responseInstance = FrameworkBootstrap::getResponseInstance();
 
                // Is the template engine loaded?
                if ((class_exists($tpl)) && (is_object($languageInstance))) {