Package org.platformlayer

Examples of org.platformlayer.TypedPlatformLayerClient


    if (target.client == null) {
      PlatformLayerClient client = HttpPlatformLayerClient.buildUsingConfiguration(httpStrategy,
          target.configuration);

      TypedPlatformLayerClient typedClient = new TypedPlatformLayerClient(client, mapper);
      // TODO: Save client??
      return typedClient;
    } else {
      return target.client;
    }
View Full Code Here


  void buildClients() {
    // TODO: Fork/Join?

    for (FederationMapping key : federationMap.getAllTargetKeys()) {
      TypedPlatformLayerClient client = federationMap.buildClient(key);

      ChildClient child = new ChildClient(key, client);
      childClients.put(key, child);
    }
View Full Code Here

        runAsProject = masterProject;
        projects.add(runAsProject);
      }
    }

    TypedPlatformLayerClient defaultClient = buildClient(runAsProject);

    FederationConfiguration federationMapConfig = FederatedPlatformLayerClient
        .buildFederationConfiguration(defaultClient);

    FederationMap federationMap = new FederationMap(httpStrategy, mapper, federationMapConfig);

    if (multitenant != null) {
      ProjectAuthorization localProject = projectAuthz; // .getProject();
      TypedPlatformLayerClient localClient = buildClient(localProject);

      FederationKey host = FederationKey.LOCAL;
      ProjectId project = localClient.getProject();
      FederationMapping mapKey = new FederationMapping(host, project);

      federationMap.addMapping(mapKey, localClient);

      for (PlatformLayerKey mappedService : multitenant.getMappedItems()) {
View Full Code Here

    return platformLayerClient;
  }

  public TypedPlatformLayerClient getTypedClient() throws IOException, OpsException {
    if (typedClient == null) {
      typedClient = new TypedPlatformLayerClient(getUntypedClient(), getMapper());
    }
    return typedClient;
  }
View Full Code Here

  private TypedItemMapper getMapper() {
    return typedItemMapper;
  }

  public <T extends ItemBase> T putItem(String id, T item) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    Class<T> itemClass = (Class<T>) item.getClass();

    item.key = PlatformLayerKey.fromId(id);
    T put = client.putItem(item);
    ownedItems.add(put);
    return put;
  }
View Full Code Here

    ownedItems.add(put);
    return put;
  }

  public <T extends ItemBase> T getItem(String id, Class<T> itemClass) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[] {});

    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, new ManagedItemId(id), itemClass,
        client.listServices(true));
    return client.getItem(key, itemClass);
  }
View Full Code Here

      waitForDeleted(item);
    }
  }

  public <T extends ItemBase> JobData deleteItem(T item) throws IOException, OpsException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey key = item.getKey();
    return client.deleteItem(key);
  }
View Full Code Here

    PlatformLayerKey key = item.getKey();
    return client.deleteItem(key);
  }

  public <T extends ItemBase> JobData doAction(T item, Action action) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey key = item.getKey();
    return client.doAction(key, action);
  }
View Full Code Here

    return new InetSocketAddress(address, endpoint.port);
  }

  public JobData waitForJobComplete(JobData job, TimeSpan timeout) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey jobKey = job.key;

    long startedAt = System.currentTimeMillis();

    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        throw new IllegalStateException("Interrupted", e);
      }

      if (timeout != null && timeout.hasTimedOut(startedAt)) {
        throw new OpsException("Timeout waiting for job completion");
      }

      // TODO: We really need a "get job status" function
      JobData found = null;
      for (JobData candidate : client.listJobs().getJobs()) {
        if (jobKey.equals(candidate.getJobKey())) {
          found = candidate;
        }
      }

      if (found == null) {
        // Assume completed?
        throw new IllegalStateException("Job not found in job list");
      }

      JobExecutionList executions = client.listJobExecutions(job.getJobKey().getItemIdString());
      JobExecutionData foundExecution = null;
      for (JobExecutionData candidate : executions) {
        if (jobKey.equals(candidate.getJobKey())) {
          foundExecution = candidate;
        }
View Full Code Here

TOP

Related Classes of org.platformlayer.TypedPlatformLayerClient

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.