public static function main($args) { $clientConnection = ClientConnectionImpl::newClient(); $identifier = new ResourceIdentifierImpl("anyem.com", "anyemNameSpace", "a"); $anyemClient = new AnyemClientImpl($clientConnection, $identifier); for ($i = 0; $i < $args[0]; $i++) { usleep(1000); try { $responseWrapper = $anyemClient->read(); } catch (Exception $e) { print $e->getMessage() . "\n"; continue; } print sprintf("variable [a] contains: %s\n", $responseWrapper->getResource()->getData()); } }
public function testGetPut() { $expected = $iteration = 2000; $clientConnection = ClientConnectionImpl::newClient(); $identifier = new ResourceIdentifierImpl("anyem.com", "anyemNameSpace", "a"); $anyemClient = new AnyemClientImpl($clientConnection, $identifier); $a = 0; for ($i = 0; $i < $iteration; $i++) { try { $responseWrapper = $anyemClient->get($a, 10, 300000); } catch (Exception $e) { print $e->getMessage() . "\n"; continue; } $a = $responseWrapper->getResource()->getData(); $anyemClient->put(++$a); } $this->assertEquals($expected, $a); }
public static function init() { if (self::$_INITIALIZED === FALSE) { $anyemConfigReader = new AnyemConfigReaderImpl(__DIR__ . '/../config/anyem_config.properties'); self::$_DEFAULT_MAX_ATTEMPT = $anyemConfigReader->readConfig(self::DEFAULT_MAX_ATTEMPT); self::$_DEFAULT_DELAY_ATTEMPT = $anyemConfigReader->readConfig(self::DEFAULT_DELAY_ATTEMPT); Logger::configure(__DIR__ . '/../config/log4php/config.xml'); self::$_LOG = Logger::getLogger(__CLASS__); self::$_INITIALIZED = TRUE; } }
public function run() { self::init(); require_once __DIR__ . '/../anyem.client.impl/AnyemClientImpl.php'; $anyemClient = new AnyemClientImpl(self::$_clientConnection, self::$_identifier); $a = 0; for ($i = 0; $i < TOTAL_ITERATION; $i++) { try { $responseWrapper = $anyemClient->get($a, MAX_ATTEMPT, DELAY_ATTEMPT); } catch (Exception $e) { print $e->getMessage() . "\n"; continue; } $a = $responseWrapper->getResource()->getData(); $anyemClient->put(++$a); } }