@Test
 public void testParams() {
   File storageDir = new File(config.getXenonConfig().getStoragePath());
   assertThat(host.getPort(), is(19000));
   Path storagePath = Paths.get(storageDir.getPath()).resolve(Integer.toString(19000));
   assertThat(host.getStorageSandbox().getPath(), is(storagePath.toString()));
 }
예제 #2
0
  private DeploymentService.State getState() {
    if (deploymentLink != null) {
      URI serviceUri = UriUtils.buildUri(xenonHost, deploymentLink);

      Operation getOperation =
          Operation.createGet(serviceUri).setUri(serviceUri).setReferer(this.xenonHost.getUri());
      OperationLatch operationLatch = new OperationLatch(getOperation);
      xenonHost.sendRequest(getOperation);
      Operation completedOperation = null;
      try {
        completedOperation = operationLatch.awaitOperationCompletion(TimeUnit.SECONDS.toMicros(90));
      } catch (Throwable e) {
        logger.error("SysConfig get failed!! ", e);
        throw new RuntimeException(e);
      }

      return completedOperation.getBody(DeploymentService.State.class);
    } else {
      QueryTask.Query kindClause =
          new QueryTask.Query()
              .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND)
              .setTermMatchValue(Utils.buildKind(DeploymentService.State.class));

      QueryTask.QuerySpecification querySpecification = new QueryTask.QuerySpecification();
      querySpecification.query = kindClause;

      Operation broadcastOp =
          xenonHost
              .getCloudStoreHelper()
              .createBroadcastPost(
                  ServiceUriPaths.CORE_LOCAL_QUERY_TASKS, ServiceUriPaths.DEFAULT_NODE_SELECTOR)
              .setBody(QueryTask.create(querySpecification).setDirect(true));
      OperationLatch operationLatch = new OperationLatch(broadcastOp);
      xenonHost.sendRequest(broadcastOp);
      Operation completedOperation = null;
      try {
        completedOperation = operationLatch.awaitOperationCompletion(TimeUnit.SECONDS.toMicros(90));
      } catch (Throwable e) {
        logger.error("SysConfig broadcastquery failed!! ", e);
        throw new RuntimeException(e);
      }

      Collection<String> documentLinks =
          QueryTaskUtils.getBroadcastQueryDocumentLinks(completedOperation);
      if (documentLinks.size() == 0) {
        return null;
      }
      this.deploymentLink = documentLinks.iterator().next();
      return getState();
    }
  }
예제 #3
0
 public static SystemConfig createInstance(PhotonControllerXenonHost xenonHost) {
   if (instance == null) {
     instance = new SystemConfig(xenonHost);
     xenonHost.setSystemConfigProvider(instance);
   }
   return instance;
 }
 @BeforeMethod
 public void setUp() throws Throwable {
   createConfig();
   host =
       new PhotonControllerXenonHost(
           config.getXenonConfig(),
           hostClientFactory,
           agentControlClientFactory,
           null,
           null,
           null);
   cloudStoreServiceGroup = new CloudStoreServiceGroup(false);
   host.registerCloudStore(cloudStoreServiceGroup);
 }
예제 #5
0
  @Override
  public boolean isBackgroundPaused() {
    if (((CloudStoreServiceGroup) xenonHost.getCloudStore()).isInstaller()) {
      return true;
    }

    DeploymentService.State state = getState();
    if (state == null) {
      logger.info("Deployment document not created yet .. isBackgroundPaused returns true");
      return true;
    }
    if (isPaused(state)) {
      return true;
    }
    if (state.state != DeploymentState.READY) {
      return true;
    }
    return false;
  }
    @Test
    public void testStoragePathDoesNotExist() throws Throwable {
      File storageDir = new File(config.getXenonConfig().getStoragePath());

      cleanupStorage();
      assertThat(storageDir.exists(), is(false));

      host =
          new PhotonControllerXenonHost(
              config.getXenonConfig(),
              hostClientFactory,
              agentControlClientFactory,
              null,
              null,
              null);
      cloudStoreServiceGroup = new CloudStoreServiceGroup(false);
      host.registerCloudStore(cloudStoreServiceGroup);
      assertThat(storageDir.exists(), is(true));
      assertThat(host, is(notNullValue()));
    }