Package org.springframework.xd.rest.client.impl

Examples of org.springframework.xd.rest.client.impl.SpringXDTemplate


   */
  public static boolean isStreamDeployed(String streamName, URL adminServer) {
    Assert.hasText(streamName, "The stream name must be specified.");
    Assert.notNull(adminServer, "The admin server must be specified.");
    boolean result = false;
    SpringXDTemplate xdTemplate = createSpringXDTemplate(adminServer);
    PagedResources<StreamDefinitionResource> resources = xdTemplate.streamOperations().list();
    Iterator<StreamDefinitionResource> resourceIter = resources.iterator();
    while (resourceIter.hasNext()) {
      StreamDefinitionResource resource = resourceIter.next();
      if (streamName.equals(resource.getName())) {
        if ("deployed".equals(resource.getStatus())) {
View Full Code Here


   */
  public static boolean waitForMetric(String name, URL adminServer, int waitTime) {
    Assert.hasText(name, "name must not be empty nor null");
    Assert.notNull(adminServer, "The admin server must be specified.");

    SpringXDTemplate xdTemplate = createSpringXDTemplate(adminServer);
    boolean result = isMetricPresent(xdTemplate, name);
    long timeout = System.currentTimeMillis() + waitTime;
    while (!result && System.currentTimeMillis() < timeout) {
      try {
        Thread.sleep(1000);
View Full Code Here

   * @param adminServer URL of the Admin Server
   * @return A new instance of SpringXDTemplate
   */
  private static SpringXDTemplate createSpringXDTemplate(URL adminServer) {
    try {
      return new SpringXDTemplate(adminServer.toURI());
    }
    catch (URISyntaxException uriException) {
      throw new IllegalStateException(uriException.getMessage(), uriException);
    }
  }
View Full Code Here

  public void testKillOneContainer() throws Exception {
    for (int i = 0; i < 3; i++) {
      startContainer();
    }

    SpringXDTemplate template = ensureTemplate();
    logger.info("Waiting for containers...");
    Map<Long, String> mapPidUuid = waitForContainers();
    logger.info("Containers running");

    String streamName = testName.getMethodName() + "-ticktock";

    template.streamOperations().createStream(streamName, "time|log", false);
    verifyStreamCreated(streamName);

    template.streamOperations().deploy(streamName, null);
    verifyStreamDeployed(streamName);

    ModuleRuntimeContainers moduleContainers = retrieveModuleRuntimeContainers(streamName);

    // kill the source
View Full Code Here

  public void testKillAllContainers() throws Exception {
      for (int i = 0; i < 2; i++) {
        startContainer();
      }

    SpringXDTemplate template = ensureTemplate();
    logger.info("Waiting for containers...");
    waitForContainers();
    logger.info("Containers running");

    String streamName = testName.getMethodName() + "-ticktock";
    template.streamOperations().createStream(streamName, "time|log", true);
    verifyStreamDeployed(streamName);

    // verify modules
    retrieveModuleRuntimeContainers(streamName);
View Full Code Here

   */
  @Test
  public void testNewContainerDeployment() throws Exception {
    String streamName = testName.getMethodName() + "-upper-case";

    SpringXDTemplate template = ensureTemplate();
    int httpPort = SocketUtils.findAvailableServerSocket();
    template.streamOperations().createStream(streamName,
        String.format("http --port=%d | transform --expression='payload.toUpperCase()' | log", httpPort),
        false);
    verifyStreamCreated(streamName);

    template.streamOperations().deploy(streamName, null);
    verifyStreamState(streamName, DeploymentUnitStatus.State.failed);

    for (int i = 0; i < 3; i++) {
      startContainer();
    }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testJobStateTransition() throws Exception {
    SpringXDTemplate template = ensureTemplate();
    String jobName = testName.getMethodName() + "-ticktock";

    String definition = String.format("timestampfile --directory=%s --format='%s' --fileExtension=%s",
        DIRECTORY, DATE_FORMAT, FILE_EXTENSION);

    String fileName = DIRECTORY + File.separatorChar + jobName + '.' + FILE_EXTENSION;

    try {
      template.jobOperations().createJob(jobName, definition, false);
      verifyJobCreated(jobName);
      verifyJobState(jobName, DeploymentUnitStatus.State.undeployed);

      template.jobOperations().deploy(jobName, null);
      verifyJobState(jobName, DeploymentUnitStatus.State.failed);

      startContainer();
      Map<Long, String> mapPidUuid = waitForContainers();
      assertEquals(1, mapPidUuid.size());

      verifyJobState(jobName, DeploymentUnitStatus.State.deployed);
      template.jobOperations().launchJob(jobName, null);
      assertThat(fileName, fileUpdated(System.currentTimeMillis()));

      shutdownContainer(mapPidUuid.keySet().iterator().next());
      waitForContainers();
      verifyJobState(jobName, DeploymentUnitStatus.State.failed);
View Full Code Here

   */
  @Override
  public SpringXDTemplate ensureTemplate() {
    if (template == null) {
      try {
        template = new SpringXDTemplate(new URI(adminUrl));
      }
      catch (URISyntaxException e) {
        throw new IllegalArgumentException(e);
      }
    }
View Full Code Here

  public void testIncompleteState() throws Exception {
    for (int i = 0; i < 2; i++) {
      startContainer();
    }

    SpringXDTemplate template = ensureTemplate();
    logger.info("Waiting for containers...");
    Map<Long, String> mapPidUuid = waitForContainers();
    logger.info("Containers running");

    String streamName = testName.getMethodName() + "-ticktock";

    template.streamOperations().createStream(streamName, "time|log", false);
    verifyStreamCreated(streamName);

    template.streamOperations().deploy(streamName, "module.log.count=2");
    verifyStreamDeployed(streamName);

    ModuleRuntimeContainers moduleContainers = retrieveModuleRuntimeContainers(streamName);
    Set<String> sinks = new HashSet<String>(moduleContainers.getSinkContainers());
    sinks.removeAll(moduleContainers.getSourceContainers());
View Full Code Here

    for (int i = 0; i < 2; i++) {
      startContainer(systemProperties);
    }

    SpringXDTemplate template = ensureTemplate();
    logger.info("Waiting for containers...");
    waitForContainers();
    logger.info("Containers running");

    String streamName = testName.getMethodName() + "-woodchuck";
    File file = File.createTempFile("temp", ".txt");
    file.deleteOnExit();
    int httpPort = SocketUtils.findAvailableServerSocket();
    template.streamOperations().createStream(
        streamName,
        String.format("http --port=%s | splitter --expression=payload.split(' ') | " +
            "file --dir=%s --name=${xd.container.id}", httpPort, file.getParent()), false);
    verifyStreamCreated(streamName);

    template.streamOperations().deploy(streamName,
        "module.splitter.producer.partitionKeyExpression=payload,module.file.count=2");

    // verify modules
    Map<String, Properties> modules = new HashMap<String, Properties>();
    int attempts = 0;
    while (attempts++ < 60) {
      Thread.sleep(500);
      for (ModuleMetadataResource module : template.runtimeOperations().listDeployedModules()) {
        modules.put(module.getContainerId() + ":" + module.getModuleType() + ":" + module.getName(),
            module.getDeploymentProperties());
      }
      if (modules.size() == 4) {
        break;
View Full Code Here

TOP

Related Classes of org.springframework.xd.rest.client.impl.SpringXDTemplate

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.