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());
}
}
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);
}
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);
}
});
}
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);
}
Aggregations