Examples of SCClient


Examples of org.serviceconnector.api.cln.SCClient

        List<String> networkInterfaces = myLocalListenerConfiguration.getNetworkInterfaces();
        for (String networkInterface : networkInterfaces) {
          String host = networkInterface;
          int port = myLocalListenerConfiguration.getPort();
          try {
            SCClient localClient = new SCClient(host, port, ConnectionType.NETTY_TCP);
            localClient.attach();
            return localClient;
          } catch (Exception e) {
            LOGGER.warn("upload current log files, connect to network interface " + host + " failed. " + e.toString());
          }
        }
      }
      responder = responderRegistry.getFirstResponderForConnectionType(ConnectionType.NETTY_HTTP);
      if (responder != null) {
        ListenerConfiguration myLocalListenerConfiguration = responder.getListenerConfig();
        List<String> networkInterfaces = myLocalListenerConfiguration.getNetworkInterfaces();
        // no netty tcp endpoint is available, try to get netty http
        for (String networkInterface : networkInterfaces) {
          String host = networkInterface;
          int port = myLocalListenerConfiguration.getPort();
          try {
            SCClient localClient = new SCClient(host, port, ConnectionType.NETTY_HTTP);
            localClient.attach();
            return localClient;
          } catch (Exception e) {
            LOGGER.warn("upload current log files, connect to network interface " + host + " and port " + port
                + " failed. " + e.toString());
          }
        }
      }
      return null;
    }
    if (service instanceof CascadedFileService) {
      CascadedFileService cascadedFileService = (CascadedFileService) service;
      CascadedSC cascadedSC = cascadedFileService.getCascadedSC();
      String host = cascadedSC.getHost();
      int port = cascadedSC.getPortNr();
      String connectionType = cascadedSC.getConnectionType();
      try {
        SCClient localClient = new SCClient(host, port, ConnectionType.getType(connectionType));
        localClient.attach();
        return localClient;
      } catch (Exception e) {
        LOGGER.warn("upload current log files, connect to network interface " + host + " and port " + port + " failed. "
            + e.toString());
      }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

  }

  @Before
  public void beforeOneTest() throws Exception {
    super.beforeOneTest();
    client = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    client.attach();
  }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

  /**
   * Run example.
   */
  public void runExample() {
    SCClient sc = null;
    SCPublishService publishServiceA = null;
    try {
      sc = new SCClient("localhost", 7000);
      sc.setMaxConnections(100);

      // connects to SC, checks connection to SC
      sc.attach();

      publishServiceA = sc.newPublishService("publish-1");
      SCMessageCallback callback = new TestPublishCallback(publishServiceA);
      SCSubscribeMessage subscibeMessage = new SCSubscribeMessage();
      subscibeMessage.setMask("000012100012832102FADF-----------X-----------");
      subscibeMessage.setSessionInfo("sessionInfo");
      publishServiceA.subscribe(subscibeMessage, callback);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        // disconnects from SC
        publishServiceA.unsubscribe();
        sc.detach();
      } catch (Exception e) {
        sc = null;
      }
    }
  }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

    // 1: disconnect client to top level (cascaded) SC
    this.sessionService1.deleteSession();
    this.sessionClient.detach();

    // 2: connect new client to SC0
    SCClient clientToSc0 = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    clientToSc0.attach();
    SCSessionService sessionSrvToSC0 = clientToSc0.newSessionService(TestConstants.sesServiceName1);

    // 3: load data to cache (cid=700) on SC0
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionSrvToSC0.createSession(new SCMessage(), new SessionMsgCallback(sessionSrvToSC0));
    sessionSrvToSC0.execute(request);

    // 4: start cache guardian - publish 3 large appendix
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    subMsg.setData("700");
    clientToSc0.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 5: verify callback retrieval - 3 appendix within 10sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);

    // 6: verify data is in cache on SC0
    Map<String, String> inspectResponse = clientToSc0.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
        "700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);

    // 7: start cache guardian over top level (cascaded) SC - doing nothing
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 8: stop cache guardian over SC0 - cached managed data should stay
    clientToSc0.stopCacheGuardian();

    // 9: verify data is still in cache on SC0
    inspectResponse = clientToSc0.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
        "700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);

    // 10: verify data is NOT in top level cache
    inspectResponse = this.mgmtClient.inspectCache("700");
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

  public void t41_cc_2SC0() throws Exception {
    // start up additional SC0A and Servers for this test
    this.startSC0AAndServers();

    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 of client1 - do nothing
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: start cache guardian1A of client2 - publish 3 large appendix
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1A, subMsg, cacheGuardianCbk2);

    // 5: verify callback of client2 guardian1A retrieval - 3 appendix within 10sec
    cacheGuardianCbk2.waitForAppendMessage(3, 10);

    // 6: verify callback of client1 guardian1 retrieval - 0 appendix within 3sec
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

  public void t42_cc_2SC0() throws Exception {
    // start up additional SC0A and Servers for this test
    this.startSC0AAndServers();

    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 of client1 - publish 1 large initial
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.publish1LargeInitialMsgCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: verify callback of client1 guardian1 retrieval - 1 large initial message within 10sec
    cacheGuardianCbk.waitForMessage(1, 10);

    // 5: start cache guardian1A of client2 - publish 1 large initial
    subMsg.setSessionInfo(TestConstants.publish1LargeInitialMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1A, subMsg, cacheGuardianCbk2);

    // 6: verify callback of client2 guardian1A retrieval - 1 large initial message within 10sec
    cacheGuardianCbk2.waitForMessage(1, 10);

    // 7: verify callback of client1 guardian1 retrieval - 0 large initial message within 2sec
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

   * Description: two clients subscribe to a message queue, the server gets destroyed<br>
   * Expectation: clients get a not found error, passes
   */
  @Test
  public void t95_TwoSubscribersServerGetsDestroyed() throws Exception {
    SCClient client2 = new SCClient(TestConstants.HOST, TestConstants.PORT_SC2_TCP, ConnectionType.NETTY_TCP);
    client2.attach();
    SCPublishService service1 = client.newPublishService(TestConstants.pubServiceName1);
    SCPublishService service2 = client2.newPublishService(TestConstants.pubServiceName1);

    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    @SuppressWarnings("unused")
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(10);

    MsgCallback cbk1 = new MsgCallback(service1);
    MsgCallback cbk2 = new MsgCallback(service2);

    subMsgResponse = service1.subscribe(subMsgRequest, cbk1);
    subMsgResponse = service2.subscribe(subMsgRequest, cbk2);

    // destroy the server
    SystemSuperTest.ctrl.stopServerEnvironment(SystemSuperTest.srvCtxs);
    cbk1.waitForMessage(2);
    cbk2.waitForMessage(2);

    Assert.assertFalse("service1 is still active", service1.isActive());
    Assert.assertFalse("service2 is still active", service2.isActive());
    client2.detach();
  }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

   * Description: two clients subscribe to a message queue, the server gets destroyed<br>
   * Expectation: clients get a not found error, passes
   */
  @Test
  public void t95_TwoSubscribersServerGetsDestroyed() throws Exception {
    SCClient client2 = new SCClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
    client2.attach();
    SCPublishService service1 = client.newPublishService(TestConstants.pubServiceName1);
    SCPublishService service2 = client2.newPublishService(TestConstants.pubServiceName1);

    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(10);

    MsgCallback cbk1 = new MsgCallback(service1);
    MsgCallback cbk2 = new MsgCallback(service2);

    subMsgResponse = service1.subscribe(subMsgRequest, cbk1);
    subMsgResponse = service2.subscribe(subMsgRequest, cbk2);

    // destroy the server
    SystemSuperTest.ctrl.stopServerEnvironment(SystemSuperTest.srvCtxs);
    cbk1.waitForMessage(2);
    cbk2.waitForMessage(2);

    Assert.assertFalse("service1 is still active", service1.isActive());
    Assert.assertFalse("service2 is still active", service2.isActive());
    client2.detach();
  }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

   * Description: two clients subscribe to a message queue, the server gets destroyed<br>
   * Expectation: clients get a not found error, passes
   */
  @Test
  public void t95_TwoSubscribersServerGetsDestroyed() throws Exception {
    SCClient client2 = new SCClient(TestConstants.HOST, TestConstants.PORT_SC1_TCP, ConnectionType.NETTY_TCP);
    client2.attach();
    SCPublishService service1 = client.newPublishService(TestConstants.pubServiceName1);
    SCPublishService service2 = client2.newPublishService(TestConstants.pubServiceName1);

    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage(TestConstants.pangram);
    subMsgRequest.setDataLength(TestConstants.pangram.length());
    SCSubscribeMessage subMsgResponse = null;
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(10);

    MsgCallback cbk1 = new MsgCallback(service1);
    MsgCallback cbk2 = new MsgCallback(service2);

    subMsgResponse = service1.subscribe(subMsgRequest, cbk1);
    subMsgResponse = service2.subscribe(subMsgRequest, cbk2);

    // destroy the server
    SystemSuperTest.ctrl.stopServerEnvironment(SystemSuperTest.srvCtxs);
    cbk1.waitForMessage(2);
    cbk2.waitForMessage(2);

    Assert.assertFalse("service1 is still active", service1.isActive());
    Assert.assertFalse("service2 is still active", service2.isActive());
    client2.detach();
  }
View Full Code Here

Examples of org.serviceconnector.api.cln.SCClient

   * Expectation: passes
   */
  @Test
  public void t30_cc_2Clients1Cache() throws Exception {
    // 1: connect new client2 to top level (cascaded) SC
    SCClient client2 = new SCClient(TestConstants.HOST, sessionClient.getPort(), ConnectionType.NETTY_TCP);
    client2.attach();
    SCSessionService sessionService2 = client2.newSessionService(TestConstants.sesServiceName1);
    sessionService2.createSession(new SCMessage(), new SessionMsgCallback(sessionService2));

    // 2: load data to cache (cid=700) by client1
    SCMessage request = new SCMessage();
    request.setData("cacheFor1Hour_managedData");
    request.setCacheId("700");
    request.setMessageInfo(TestConstants.cacheCmd);
    sessionService1.execute(request);

    // 3: start cache guardian1 for client1 - do nothing
    SCSubscribeMessage subMsg = new SCSubscribeMessage();
    subMsg.setMask(TestConstants.mask);
    subMsg.setData("700");
    subMsg.setSessionInfo(TestConstants.doNothingCmd);
    guardianClient.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk);

    // 4: start cache guardian1 for client2 - publish 3 large appendix
    subMsg.setSessionInfo(TestConstants.publish3LargeAppendixMsgCmd);
    GuardianCbk cacheGuardianCbk2 = new GuardianCbk();
    client2.startCacheGuardian(TestConstants.cacheGuardian1, subMsg, cacheGuardianCbk2);

    // 5: verify callback of guardian1 retrieval - 3 appendix within 100sec
    cacheGuardianCbk.waitForAppendMessage(3, 10);

    // 6: verify callback of guardian1 retrieval - 3 appendix within 100sec
    cacheGuardianCbk2.waitForAppendMessage(3, 10);

    // 7: verify data is now in top level cache
    Map<String, String> inspectResponse = guardianClient.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
        "700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);

    // 8: stop cache guardian of client1
    guardianClient.stopCacheGuardian();

    // 9: verify data is still now in top level cache
    inspectResponse = guardianClient.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "success", SC_CACHE_ENTRY_STATE.LOADED, "700", "3",
        "700/0/0=0&700/1/0=1&700/2/0=1&700/3/0=1&", TestConstants.cacheGuardian1);

    // 10: stop cache guardian of client2
    client2.stopCacheGuardian();

    // 11: verify data is now NOT in top level cache
    inspectResponse = guardianClient.inspectCache("700");
    this.checkCacheInspectString(inspectResponse, "notfound", SC_CACHE_ENTRY_STATE.LOADED, "", "", "");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.