use of com.hortonworks.streamline.streams.catalog.TopologyVersion in project streamline by hortonworks.
the class StreamsModule method setupPlaceholderTopologyVersionInfo.
private void setupPlaceholderTopologyVersionInfo(StreamCatalogService catalogService) {
if (transactionManager == null)
throw new RuntimeException("TransactionManager is not initialized");
// it's one time setup hence just use it as local variable
ManagedTransaction mt = new ManagedTransaction(transactionManager, TransactionIsolation.DEFAULT);
try {
mt.executeConsumer(() -> {
TopologyVersion versionInfo = catalogService.getTopologyVersionInfo(StreamCatalogService.PLACEHOLDER_ID);
if (versionInfo == null) {
TopologyVersion topologyVersion = new TopologyVersion();
topologyVersion.setId(StreamCatalogService.PLACEHOLDER_ID);
topologyVersion.setTopologyId(StreamCatalogService.PLACEHOLDER_ID);
topologyVersion.setName("PLACEHOLDER_VERSIONINFO");
topologyVersion.setDescription("PLACEHOLDER_VERSIONINFO");
topologyVersion.setTimestamp(System.currentTimeMillis());
catalogService.addOrUpdateTopologyVersionInfo(StreamCatalogService.PLACEHOLDER_ID, topologyVersion);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.hortonworks.streamline.streams.catalog.TopologyVersion in project streamline by hortonworks.
the class StreamCatalogService method getTopologyVersionInfo.
public TopologyVersion getTopologyVersionInfo(Long versionId) {
TopologyVersion topologyVersion = new TopologyVersion();
topologyVersion.setId(versionId);
return dao.get(topologyVersion.getStorableKey());
}
use of com.hortonworks.streamline.streams.catalog.TopologyVersion in project streamline by hortonworks.
the class StreamCatalogService method addCurrentTopologyVersionInfo.
// create a 'CURRENT' version for given topology id
private TopologyVersion addCurrentTopologyVersionInfo(Long topologyId, Long timestamp) {
TopologyVersion versionInfo = new TopologyVersion();
versionInfo.setName(CURRENT_VERSION);
versionInfo.setDescription("");
versionInfo.setTimestamp(timestamp);
versionInfo.setTopologyId(topologyId);
return addTopologyVersionInfo(versionInfo);
}
use of com.hortonworks.streamline.streams.catalog.TopologyVersion in project streamline by hortonworks.
the class StreamCatalogService method listTopologyEditorMetadata.
public Collection<TopologyEditorMetadata> listTopologyEditorMetadata() {
List<TopologyEditorMetadata> metadatas = new ArrayList<>();
Collection<TopologyVersion> currentVersions = listCurrentTopologyVersionInfos();
for (TopologyVersion version : currentVersions) {
List<QueryParam> queryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(version.getTopologyId(), version.getId(), null);
metadatas.addAll(listTopologyEditorMetadata(queryParams));
}
return metadatas;
}
use of com.hortonworks.streamline.streams.catalog.TopologyVersion in project streamline by hortonworks.
the class StreamCatalogServiceTest method testListTopologiesProvidesVersionedTimestamp_STREAMLINE_526.
@Test
public void testListTopologiesProvidesVersionedTimestamp_STREAMLINE_526() {
List<Topology> topologies = new ArrayList<>();
topologies.add(createTopology(1L));
topologies.add(createTopology(2L));
topologies.add(createTopology(3L));
List<TopologyVersion> versions = topologies.stream().map(x -> createTopologyVersionInfo(x.getId(), x.getId())).collect(Collectors.toList());
new Expectations() {
{
dao.find(withEqual(new Topology().getNameSpace()), withAny(new ArrayList<>()));
result = topologies;
dao.find(withEqual(new TopologyVersion().getNameSpace()), withAny(new ArrayList<>()));
result = versions;
dao.get(withEqual(new StorableKey(versions.get(0).getNameSpace(), versions.get(0).getPrimaryKey())));
result = versions.get(0);
dao.get(withEqual(new StorableKey(versions.get(1).getNameSpace(), versions.get(1).getPrimaryKey())));
result = versions.get(1);
dao.get(withEqual(new StorableKey(versions.get(2).getNameSpace(), versions.get(2).getPrimaryKey())));
result = versions.get(2);
}
};
Collection<Topology> result = streamCatalogService.listTopologies();
assertTrue(result.size() > 0);
assertFalse(result.stream().anyMatch(x -> x.getVersionTimestamp() == null));
}
Aggregations