Search in sources :

Example 1 with TopologyVersion

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);
    }
}
Also used : TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) ManagedTransaction(com.hortonworks.registries.storage.transaction.ManagedTransaction)

Example 2 with TopologyVersion

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());
}
Also used : TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion)

Example 3 with TopologyVersion

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);
}
Also used : TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion)

Example 4 with TopologyVersion

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;
}
Also used : TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) ArrayList(java.util.ArrayList) TopologyEditorMetadata(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata)

Example 5 with TopologyVersion

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));
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) MLModelRegistryClient(com.hortonworks.streamline.registries.model.client.MLModelRegistryClient) Arrays(java.util.Arrays) Expectations(mockit.Expectations) FileStorage(com.hortonworks.registries.common.util.FileStorage) RunWith(org.junit.runner.RunWith) ArrayList(java.util.ArrayList) Map(java.util.Map) Projection(com.hortonworks.streamline.streams.catalog.Projection) JMockit(mockit.integration.junit4.JMockit) TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) Tested(mockit.Tested) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) List(java.util.List) TreeMap(java.util.TreeMap) Assert.assertFalse(org.junit.Assert.assertFalse) Injectable(mockit.Injectable) Assert(org.junit.Assert) StorableKey(com.hortonworks.registries.storage.StorableKey) StorageManager(com.hortonworks.registries.storage.StorageManager) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Expectations(mockit.Expectations) TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) StorableKey(com.hortonworks.registries.storage.StorableKey) ArrayList(java.util.ArrayList) Topology(com.hortonworks.streamline.streams.catalog.Topology) Test(org.junit.Test)

Aggregations

TopologyVersion (com.hortonworks.streamline.streams.catalog.TopologyVersion)13 Timed (com.codahale.metrics.annotation.Timed)3 Path (javax.ws.rs.Path)3 StorableKey (com.hortonworks.registries.storage.StorableKey)2 Topology (com.hortonworks.streamline.streams.catalog.Topology)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 QueryParam (com.hortonworks.registries.common.QueryParam)1 FileStorage (com.hortonworks.registries.common.util.FileStorage)1 StorageManager (com.hortonworks.registries.storage.StorageManager)1 ManagedTransaction (com.hortonworks.registries.storage.transaction.ManagedTransaction)1 BadRequestException (com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException)1 EntityNotFoundException (com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException)1 StreamingEngineNotReachableException (com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException)1 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)1 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)1 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)1 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)1 MLModelRegistryClient (com.hortonworks.streamline.registries.model.client.MLModelRegistryClient)1 Projection (com.hortonworks.streamline.streams.catalog.Projection)1