@Override public void OutgoingChannelConnected(AsyncClientChannel channel) { LOG.info("Connected to Directory Server. Initiating Registration"); DirectoryServiceRegistrationInfo registrationInfo = new DirectoryServiceRegistrationInfo(); _connectionCookie = System.currentTimeMillis(); registrationInfo.setConnectionString( _address.getAddress().getHostAddress() + ":" + _address.getPort()); registrationInfo.setRegistrationCookie(_connectionCookie); try { _serviceStub.register( registrationInfo, new AsyncRequest.Callback<DirectoryServiceRegistrationInfo, NullMessage>() { @Override public void requestComplete( AsyncRequest<DirectoryServiceRegistrationInfo, NullMessage> request) {} }); } catch (IOException e) { LOG.error(CCStringUtils.stringifyException(e)); _eventLoop.stop(); } }
public DirectoryServiceTester(InetSocketAddress address) { _eventLoop = new EventLoop(); _address = address; _eventLoop.start(); // create server channel ... AsyncServerChannel channel = new AsyncServerChannel(this, _eventLoop, _address, this); // register RPC services it supports ... registerService(channel, DirectoryServiceCallback.spec); try { start(); } catch (IOException e) { LOG.error(CCStringUtils.stringifyException(e)); _eventLoop.stop(); return; } _eventLoop.setTimer( new Timer( 0, false, new Timer.Callback() { @Override public void timerFired(Timer timer) { connect(); } })); }
void startTest() { LOG.info("Starting Tests"); DirectoryServiceSubscriptionInfo subscription = new DirectoryServiceSubscriptionInfo(); subscription.setSubscriptionPath("/test/zzz/.*"); try { LOG.info("Subscribing to .*"); _serviceStub.subscribe( subscription, new AsyncRequest.Callback<DirectoryServiceSubscriptionInfo, DirectoryServiceItemList>() { @Override public void requestComplete( AsyncRequest<DirectoryServiceSubscriptionInfo, DirectoryServiceItemList> request) { dumpItemList(request.getOutput()); try { long currentTime = System.currentTimeMillis(); LOG.info("Subscription Successfull. Publishing Items... Seed:" + currentTime); publishTestItem("/test/foo/bar", "bar" + currentTime); publishTestItem("/test/foo/bar2", "bar2" + currentTime); publishTestItem("/test/foo/bar3", "bar3" + currentTime); publishTestItem("/test/zzz/bar", "zbar" + currentTime); publishTestItem("/test/zzz/bar2", "zbar2" + currentTime); publishTestItem("/test/zzz/bar3", "zbar3" + currentTime); LOG.info("Publish Successfull. querying Items..."); // queryItem("/test/foo/bar"); // queryItem("/test/foo/bar2"); // queryItem("/test/foo/bar3"); // queryItem("/test/zzz/bar"); // queryItem("/test/zzz/bar2"); // queryItem("/test/zzz/bar3"); LOG.info("Done..."); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } catch (IOException e) { LOG.error(CCStringUtils.stringifyException(e)); } }