Package org.serviceconnector.api.cln

Examples of org.serviceconnector.api.cln.SCMgmtClient


  }

  public void setUpClientToSC() throws Exception {
    if (client == null) {  // client may be already created and attached because the of the class hierarchy
      if (cascadingLevel == 0) {
        client = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP, ConnectionType.NETTY_TCP);
        client.attach();
      } else if (cascadingLevel == 1) {
        client = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC1_TCP, ConnectionType.NETTY_TCP);
        client.attach();
      } else if (cascadingLevel == 2) {
        client = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC2_TCP, ConnectionType.NETTY_TCP);
        client.attach();
      }
    }
  }
View Full Code Here


      URLString urlRequestString = new URLString();
      urlRequestString.parseRequestURLString(bodyString);
      String callKey = urlRequestString.getCallKey();
      String serviceName = urlRequestString.getParamValue("serviceName");

      SCMgmtClient client = new SCMgmtClient(host, port, ConnectionType.NETTY_TCP);
      client.attach();

      if (callKey.equalsIgnoreCase(Constants.CC_CMD_KILL)) {
        client.killSC();
        System.out.println("SC exit requested");
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_DUMP)) {
        client.dump();
        System.out.println("SC dump requested");
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_CLEAR_CACHE)) {
        client.clearCache();
        System.out.println("Cache has been cleared");
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_ENABLE)) {
        try {
          client.enableService(serviceName);
          System.out.println("Service [" + serviceName + "] has been enabled");
        } catch (SCServiceException e) {
          System.out.println("Service [" + serviceName + "] does not exist!");
          status = 4;
        }
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_DISABLE)) {
        try {
          client.disableService(serviceName);
          System.out.println("Service [" + serviceName + "] has been disabled");
        } catch (SCServiceException e) {
          System.out.println("Service [" + serviceName + "] does not exist!");
          status = 4;
        }
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_STATE)) {
        try {
          Map<String, String> stateMap = client.getStateOfServices(serviceName);
          Set<Entry<String, String>> parameters = stateMap.entrySet();
          StringBuilder sb = new StringBuilder();
          if (parameters.size() == 0) {
            System.out.println("Service [" + serviceName + "] does not exist!");
            status = 4;
          } else {
            for (Entry<String, String> param : parameters) {
              sb.append("Service [");
              sb.append(param.getKey());
              sb.append("] is ");
              sb.append(param.getValue());
              sb.append("\n");
            }
            if (sb.length() > 0) {
              System.out.println(sb.toString());
            }
          }
        } catch (SCServiceException e) {
          System.out.println("Service [" + serviceName + "] does not exist!");
          status = 4;
        }
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_SESSIONS)) {
        try {
          Map<String, String> workloadMap = client.getWorkload(serviceName);
          Set<Entry<String, String>> workloads = workloadMap.entrySet();
          StringBuilder sb = new StringBuilder();
          for (Entry<String, String> param : workloads) {
            sb.append("Service [");
            sb.append(param.getKey());
            sb.append("] has ");
            sb.append(param.getValue());
            sb.append(" sessions\n");
          }
          System.out.println(sb.toString());
        } catch (SCServiceException e) {
          System.out.println("Service [" + serviceName + "] does not exist!");
          status = 4;
        }
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_SC_VERSION)) {
        try {
          String scVersion = client.getSCVersion();
          System.out.println(scVersion);
        } catch (SCServiceException e) {
          System.out.println("Getting version (SC Version) of remote SC failed.");
          status = 4;
        }
        client.detach();
      } else if (callKey.equalsIgnoreCase(Constants.CC_CMD_SERVICE_CONF)) {
        try {
          Map<String, String> serviceConf = client.getServiceConfiguration(serviceName);
          System.out.println(serviceConf);
        } catch (SCServiceException e) {
          System.out.println("Getting service [" + serviceName + "] configuration failed.");
          status = 4;
        }
        client.detach();
      } else {
        SCConsole.showError("Error - wrong call key in request string.");
        status = 3;
      }
    } catch (UnsupportedEncodingException e) {
View Full Code Here

    demoSessionClient.run();
    demoPublishClient.run();
    // demoFileClient.start();
    // sleep to assure deregister from server to SC is done!
    Thread.sleep(500);
    SCMgmtClient client = new SCMgmtClient("localhost", 9000, ConnectionType.NETTY_TCP);
    client.attach();
    client.killSC();
  }
View Full Code Here

   * Expectation: throws SCMPValidatorException
   */
  @Test(expected = SCMPValidatorException.class)
  public void t83_disabledService() throws Exception {
    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.sesServiceName1);
    clientMgmt.detach();

    SCMessage request = null;
    SCMessage response = null;
    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
View Full Code Here

    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);
    Assert.assertNotNull("the session ID is null", sessionService1.getSessionId());

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.sesServiceName1);
    clientMgmt.detach();

    // delete session
    sessionService1.deleteSession();
    Assert.assertNull("the session ID is NOT null after deleteSession()", sessionService1.getSessionId());
  }
View Full Code Here

    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.sesServiceName1);
    clientMgmt.detach();

    // execute
    request.setMessageInfo(TestConstants.echoCmd);
    response = sessionService1.execute(request);
    Assert.assertEquals("message body is not the same length", request.getDataLength(), response.getDataLength());
View Full Code Here

    sessionService1 = client.newSessionService(TestConstants.sesServiceName1);
    msgCallback1 = new MsgCallback(sessionService1);
    response = sessionService1.createSession(request, msgCallback1);

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.sesServiceName1);
    clientMgmt.detach();

    // send
    request.setMessageInfo(TestConstants.echoCmd);
    sessionService1.send(request);
    msgCallback1.waitForMessage(10);
View Full Code Here

    subMsgRequest.setSessionInfo(TestConstants.doNothingCmd);
    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.pubServiceName1);
    clientMgmt.detach();

    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
  }
View Full Code Here

    subMsgRequest.setNoDataIntervalSeconds(100);
    msgCallback = new MsgCallback(publishService);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.pubServiceName1);
    clientMgmt.detach();

    publishService.unsubscribe();
    Assert.assertNull("the session ID is not null", publishService.getSessionId());
  }
View Full Code Here

    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());

    // disable service
    SCMgmtClient clientMgmt = new SCMgmtClient(TestConstants.HOST, TestConstants.PORT_SC0_TCP);
    clientMgmt.attach();
    clientMgmt.disableService(TestConstants.pubServiceName1);
    clientMgmt.detach();

    subMsgRequest.setMask(TestConstants.mask1);
    subMsgResponse = publishService.changeSubscription(subMsgRequest);
    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.cln.SCMgmtClient

Copyright © 2018 www.massapicom. 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.