예제 #1
0
  public CatalogFramework getCatalogFramework() throws InterruptedException {
    LOGGER.info("getting framework");

    CatalogFramework catalogFramework = null;

    ServiceReference<CatalogFramework> providerRef =
        serviceManager.getServiceReference(CatalogFramework.class);
    if (providerRef != null) {
      catalogFramework = serviceManager.getService(providerRef);
    }

    return catalogFramework;
  }
예제 #2
0
  private <T extends Source> T waitForSource(String id, Class<T> type)
      throws InterruptedException, InvalidSyntaxException {
    T source = null;
    long timeoutLimit = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5);
    boolean available = false;

    while (!available) {
      if (source == null) {
        source =
            serviceManager
                .getServiceReferences(type, null)
                .stream()
                .map(serviceManager::getService)
                .filter(src -> id.equals(src.getId()))
                .findFirst()
                .orElse(null);
      }
      if (source != null) {
        available = source.isAvailable();
      }
      if (!available) {
        if (System.currentTimeMillis() > timeoutLimit) {
          fail("Source (" + id + ") was not created in a timely manner.");
        }
        Thread.sleep(100);
      }
    }
    LOGGER.info("Source {} is available.", id);
    return source;
  }
예제 #3
0
  public void setFanout(boolean fanoutEnabled) throws IOException {
    Map<String, Object> properties =
        adminConfig.getDdfConfigAdmin().getProperties(CATALOG_FRAMEWORK_PID);
    if (properties == null) {
      properties = new Hashtable<>();
    }
    if (fanoutEnabled) {
      properties.put("fanoutEnabled", "True");
    } else {
      properties.put("fanoutEnabled", "False");
    }

    serviceManager.startManagedService(CATALOG_FRAMEWORK_PID, properties);
  }
예제 #4
0
  public CatalogProvider waitForCatalogProvider() throws InterruptedException {
    LOGGER.info("Waiting for CatalogProvider to become available.");
    serviceManager.printInactiveBundles();

    CatalogProvider provider = null;
    long timeoutLimit = System.currentTimeMillis() + CATALOG_PROVIDER_TIMEOUT;
    boolean available = false;

    while (!available) {
      if (provider == null) {
        ServiceReference<CatalogProvider> providerRef =
            serviceManager.getServiceReference(CatalogProvider.class);
        if (providerRef != null) {
          provider = serviceManager.getService(providerRef);
        }
      }

      if (provider != null) {
        available = provider.isAvailable();
      }

      if (!available) {
        if (System.currentTimeMillis() > timeoutLimit) {
          LOGGER.info("CatalogProvider.isAvailable = false");
          serviceManager.printInactiveBundles();
          fail(
              String.format(
                  "Catalog provider timed out after %d minutes.",
                  TimeUnit.MILLISECONDS.toMinutes(CATALOG_PROVIDER_TIMEOUT)));
        }
        Thread.sleep(100);
      }
    }

    LOGGER.info("CatalogProvider is available.");
    return provider;
  }