Search in sources :

Example 1 with ManagedTransaction

use of com.hortonworks.registries.storage.transaction.ManagedTransaction 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 ManagedTransaction

use of com.hortonworks.registries.storage.transaction.ManagedTransaction in project streamline by hortonworks.

the class StreamsModule method setupPlaceholderTestNamespace.

private void setupPlaceholderTestNamespace(EnvironmentService environmentService) {
    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(() -> {
            Namespace testNamespace = environmentService.getNamespace(EnvironmentService.PLACEHOLDER_ID);
            if (testNamespace == null) {
                testNamespace = new Namespace();
                testNamespace.setId(EnvironmentService.PLACEHOLDER_ID);
                testNamespace.setName("Test Environment");
                testNamespace.setStreamingEngine(MappedTopologyActionsImpl.STORM.name());
                // no metric service, no log search service
                testNamespace.setDescription("Empty environment to test the topology which doesn't require external service.");
                testNamespace.setInternal(true);
                testNamespace.setTimestamp(System.currentTimeMillis());
                environmentService.addOrUpdateNamespace(EnvironmentService.PLACEHOLDER_ID, testNamespace);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : ManagedTransaction(com.hortonworks.registries.storage.transaction.ManagedTransaction) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace)

Aggregations

ManagedTransaction (com.hortonworks.registries.storage.transaction.ManagedTransaction)2 TopologyVersion (com.hortonworks.streamline.streams.catalog.TopologyVersion)1 Namespace (com.hortonworks.streamline.streams.cluster.catalog.Namespace)1