Search in sources :

Example 1 with StormRestAPIClient

use of com.hortonworks.streamline.streams.storm.common.StormRestAPIClient in project streamline by hortonworks.

the class StormTopologyActionsImpl method init.

@Override
public void init(Map<String, Object> conf) {
    this.conf = conf;
    if (conf != null) {
        if (conf.containsKey(StormTopologyLayoutConstants.STORM_ARTIFACTS_LOCATION_KEY)) {
            stormArtifactsLocation = (String) conf.get(StormTopologyLayoutConstants.STORM_ARTIFACTS_LOCATION_KEY);
        }
        if (conf.containsKey(StormTopologyLayoutConstants.STORM_HOME_DIR)) {
            String stormHomeDir = (String) conf.get(StormTopologyLayoutConstants.STORM_HOME_DIR);
            if (!stormHomeDir.endsWith(File.separator)) {
                stormHomeDir += File.separator;
            }
            stormCliPath = stormHomeDir + "bin" + File.separator + "storm";
        }
        this.stormJarLocation = (String) conf.get(StormTopologyLayoutConstants.STORM_JAR_LOCATION_KEY);
        catalogRootUrl = (String) conf.get(StormTopologyLayoutConstants.YAML_KEY_CATALOG_ROOT_URL);
        Map<String, String> env = System.getenv();
        String javaHomeStr = env.get("JAVA_HOME");
        if (StringUtils.isNotEmpty(javaHomeStr)) {
            if (!javaHomeStr.endsWith(File.separator)) {
                javaHomeStr += File.separator;
            }
            javaJarCommand = javaHomeStr + "bin" + File.separator + "jar";
        } else {
            javaJarCommand = "jar";
        }
        String stormApiRootUrl = (String) conf.get(TopologyLayoutConstants.STORM_API_ROOT_URL_KEY);
        Subject subject = (Subject) conf.get(TopologyLayoutConstants.SUBJECT_OBJECT);
        Client restClient = ClientBuilder.newClient(new ClientConfig());
        this.client = new StormRestAPIClient(restClient, stormApiRootUrl, subject);
        nimbusSeeds = (String) conf.get(NIMBUS_SEEDS);
        nimbusPort = Integer.valueOf((String) conf.get(NIMBUS_PORT));
        if (conf.containsKey(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)) {
            nimbusThriftMaxBufferSize = (Long) conf.get(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
        } else {
            nimbusThriftMaxBufferSize = DEFAULT_NIMBUS_THRIFT_MAX_BUFFER_SIZE;
        }
        setupSecuredStormCluster(conf);
        EnvironmentService environmentService = (EnvironmentService) conf.get(TopologyLayoutConstants.ENVIRONMENT_SERVICE_OBJECT);
        Number namespaceId = (Number) conf.get(TopologyLayoutConstants.NAMESPACE_ID);
        this.serviceConfigurationReader = new AutoCredsServiceConfigurationReader(environmentService, namespaceId.longValue());
    }
    File f = new File(stormArtifactsLocation);
    if (!f.exists() && !f.mkdirs()) {
        throw new RuntimeException("Could not create directory " + f.getAbsolutePath());
    }
}
Also used : EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Client(javax.ws.rs.client.Client) StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient) ClientConfig(org.glassfish.jersey.client.ClientConfig) File(java.io.File) Subject(javax.security.auth.Subject) StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient)

Example 2 with StormRestAPIClient

use of com.hortonworks.streamline.streams.storm.common.StormRestAPIClient in project streamline by hortonworks.

the class StormTopologyTimeSeriesMetricsImplTest method setUp.

@Before
public void setUp() throws IOException {
    source = getSourceLayoutForTest();
    processor = getProcessorLayoutForTest();
    sink = getSinkLayoutForTest();
    topology = getTopologyLayoutForTest();
    String generatedTopologyName = StormTopologyUtil.generateStormTopologyName(topology.getId(), topology.getName());
    mockedTopologyName = generatedTopologyName + "-old";
    StormRestAPIClient mockClient = createMockStormRestAPIClient(mockedTopologyName);
    stormTopologyTimeSeriesMetrics = new StormTopologyTimeSeriesMetricsImpl(mockClient);
    stormTopologyTimeSeriesMetrics.setTimeSeriesQuerier(mockTimeSeriesQuerier);
}
Also used : StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient) Before(org.junit.Before)

Example 3 with StormRestAPIClient

use of com.hortonworks.streamline.streams.storm.common.StormRestAPIClient in project streamline by hortonworks.

the class StormTopologyMetricsImpl method init.

/**
 * {@inheritDoc}
 */
@Override
public void init(Map<String, Object> conf) throws ConfigException {
    String stormApiRootUrl = null;
    Subject subject = null;
    if (conf != null) {
        stormApiRootUrl = (String) conf.get(TopologyLayoutConstants.STORM_API_ROOT_URL_KEY);
        subject = (Subject) conf.get(TopologyLayoutConstants.SUBJECT_OBJECT);
    }
    Client restClient = ClientBuilder.newClient(new ClientConfig());
    this.client = new StormRestAPIClient(restClient, stormApiRootUrl, subject);
    timeSeriesMetrics = new StormTopologyTimeSeriesMetricsImpl(client);
    topologyRetrieveCache = CacheBuilder.newBuilder().maximumSize(MAX_SIZE_TOPOLOGY_CACHE).expireAfterWrite(CACHE_DURATION_SECS, TimeUnit.SECONDS).build(new CacheLoader<Pair<String, String>, Map<String, ?>>() {

        @Override
        public Map<String, ?> load(Pair<String, String> stormTopologyIdAndAsUser) {
            String stormTopologyId = stormTopologyIdAndAsUser.getLeft();
            String asUser = stormTopologyIdAndAsUser.getRight();
            LOG.debug("retrieving topology info - topology id: {}, asUser: {}", stormTopologyId, asUser);
            return client.getTopology(stormTopologyId, asUser);
        }
    });
    componentRetrieveCache = CacheBuilder.newBuilder().maximumSize(MAX_SIZE_COMPONENT_CACHE).expireAfterWrite(CACHE_DURATION_SECS, TimeUnit.SECONDS).build(new CacheLoader<Pair<Pair<String, String>, String>, Map<String, ?>>() {

        @Override
        public Map<String, ?> load(Pair<Pair<String, String>, String> componentIdAndAsUserPair) {
            String topologyId = componentIdAndAsUserPair.getLeft().getLeft();
            String componentId = componentIdAndAsUserPair.getLeft().getRight();
            String asUser = componentIdAndAsUserPair.getRight();
            LOG.debug("retrieving component info - topology id: {}, component id: {}, asUser: {}", topologyId, componentId, asUser);
            return client.getComponent(topologyId, componentId, asUser);
        }
    });
}
Also used : CacheLoader(com.google.common.cache.CacheLoader) Client(javax.ws.rs.client.Client) StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient) ClientConfig(org.glassfish.jersey.client.ClientConfig) Subject(javax.security.auth.Subject) StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 4 with StormRestAPIClient

use of com.hortonworks.streamline.streams.storm.common.StormRestAPIClient in project streamline by hortonworks.

the class StormTopologySamplingService method init.

@Override
public void init(Map<String, Object> conf) {
    String stormApiRootUrl = null;
    Subject subject = null;
    if (conf != null) {
        stormApiRootUrl = (String) conf.get(TopologyLayoutConstants.STORM_API_ROOT_URL_KEY);
        subject = (Subject) conf.get(TopologyLayoutConstants.SUBJECT_OBJECT);
    }
    Client restClient = ClientBuilder.newClient(new ClientConfig());
    this.client = new StormRestAPIClient(restClient, stormApiRootUrl, subject);
}
Also used : StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient) Client(javax.ws.rs.client.Client) ClientConfig(org.glassfish.jersey.client.ClientConfig) Subject(javax.security.auth.Subject) StormRestAPIClient(com.hortonworks.streamline.streams.storm.common.StormRestAPIClient)

Aggregations

StormRestAPIClient (com.hortonworks.streamline.streams.storm.common.StormRestAPIClient)4 Subject (javax.security.auth.Subject)3 Client (javax.ws.rs.client.Client)3 ClientConfig (org.glassfish.jersey.client.ClientConfig)3 CacheLoader (com.google.common.cache.CacheLoader)1 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)1 File (java.io.File)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1 Before (org.junit.Before)1