Search in sources :

Example 11 with StreamMetadataCache

use of org.apache.samza.system.StreamMetadataCache in project samza by apache.

the class ClusterBasedJobCoordinator method getPartitionCountMonitor.

private StreamPartitionCountMonitor getPartitionCountMonitor(Config config, SystemAdmins systemAdmins) {
    StreamMetadataCache streamMetadataCache = new StreamMetadataCache(systemAdmins, 0, SystemClock.instance());
    return new StreamPartitionCountMonitorFactory(streamMetadataCache, this.metrics).build(config, streamsChanged -> {
        // Fail the jobs with durable state store. Otherwise, application state.status remains UNDEFINED s.t. YARN job will be restarted
        if (hasDurableStores) {
            LOG.error("Input topic partition count changed in a job with durable state. Failing the job. Changed topics: {}", streamsChanged.toString());
            state.status = SamzaApplicationState.SamzaAppStatus.FAILED;
        }
        coordinatorException = new PartitionChangeException("Input topic partition count changes detected for topics: " + streamsChanged.toString());
    });
}
Also used : StreamMetadataCache(org.apache.samza.system.StreamMetadataCache) PartitionChangeException(org.apache.samza.coordinator.PartitionChangeException) StreamPartitionCountMonitorFactory(org.apache.samza.coordinator.StreamPartitionCountMonitorFactory)

Example 12 with StreamMetadataCache

use of org.apache.samza.system.StreamMetadataCache in project samza by apache.

the class ClusterBasedJobCoordinator method getInputRegexMonitor.

private Optional<StreamRegexMonitor> getInputRegexMonitor(JobModel jobModel, Config config, SystemAdmins systemAdmins) {
    StreamMetadataCache streamMetadataCache = new StreamMetadataCache(systemAdmins, 0, SystemClock.instance());
    return new StreamRegexMonitorFactory(streamMetadataCache, this.metrics).build(jobModel, config, (initialInputSet, newInputStreams, regexesMonitored) -> {
        if (hasDurableStores) {
            LOG.error("New input system-streams discovered. Failing the job. New input streams: {}" + " Existing input streams: {}", newInputStreams, initialInputSet);
            state.status = SamzaApplicationState.SamzaAppStatus.FAILED;
        }
        coordinatorException = new InputStreamsDiscoveredException("New input streams discovered: " + newInputStreams);
    });
}
Also used : StreamMetadataCache(org.apache.samza.system.StreamMetadataCache) InputStreamsDiscoveredException(org.apache.samza.coordinator.InputStreamsDiscoveredException) StreamRegexMonitorFactory(org.apache.samza.coordinator.StreamRegexMonitorFactory)

Example 13 with StreamMetadataCache

use of org.apache.samza.system.StreamMetadataCache in project samza by apache.

the class StaticResourceJobCoordinatorFactory method getJobCoordinator.

@Override
public JobCoordinator getJobCoordinator(String processorId, Config config, MetricsRegistry metricsRegistry, MetadataStore metadataStore) {
    JobInfoServingContext jobModelServingContext = new JobInfoServingContext();
    JobConfig jobConfig = new JobConfig(config);
    CoordinatorCommunicationContext context = new CoordinatorCommunicationContext(jobModelServingContext, config, metricsRegistry);
    CoordinatorCommunication coordinatorCommunication = new HttpCoordinatorToWorkerCommunicationFactory().coordinatorCommunication(context);
    JobCoordinatorMetadataManager jobCoordinatorMetadataManager = new JobCoordinatorMetadataManager(new NamespaceAwareCoordinatorStreamStore(metadataStore, SetJobCoordinatorMetadataMessage.TYPE), JobCoordinatorMetadataManager.ClusterType.NON_YARN, metricsRegistry);
    ChangelogStreamManager changelogStreamManager = new ChangelogStreamManager(new NamespaceAwareCoordinatorStreamStore(metadataStore, SetChangelogMapping.TYPE));
    JobRestartSignal jobRestartSignal = ReflectionUtil.getObj(new JobCoordinatorConfig(config).getJobRestartSignalFactory(), JobRestartSignalFactory.class).build(new JobRestartSignalFactoryContext(config));
    Optional<StartpointManager> startpointManager = jobConfig.getStartpointEnabled() ? Optional.of(new StartpointManager(metadataStore)) : Optional.empty();
    SystemAdmins systemAdmins = new SystemAdmins(config, StaticResourceJobCoordinator.class.getSimpleName());
    StreamMetadataCache streamMetadataCache = new StreamMetadataCache(systemAdmins, 0, SystemClock.instance());
    JobModelHelper jobModelHelper = buildJobModelHelper(metadataStore, streamMetadataCache);
    StreamPartitionCountMonitorFactory streamPartitionCountMonitorFactory = new StreamPartitionCountMonitorFactory(streamMetadataCache, metricsRegistry);
    StreamRegexMonitorFactory streamRegexMonitorFactory = new StreamRegexMonitorFactory(streamMetadataCache, metricsRegistry);
    Optional<String> executionEnvContainerId = Optional.ofNullable(System.getenv(ShellCommandConfig.ENV_EXECUTION_ENV_CONTAINER_ID));
    Optional<String> samzaEpochId = Optional.ofNullable(System.getenv(EnvironmentVariables.SAMZA_EPOCH_ID));
    return new StaticResourceJobCoordinator(processorId, jobModelHelper, jobModelServingContext, coordinatorCommunication, jobCoordinatorMetadataManager, streamPartitionCountMonitorFactory, streamRegexMonitorFactory, startpointManager, changelogStreamManager, jobRestartSignal, metricsRegistry, systemAdmins, executionEnvContainerId, samzaEpochId, config);
}
Also used : StreamMetadataCache(org.apache.samza.system.StreamMetadataCache) CoordinatorCommunicationContext(org.apache.samza.coordinator.communication.CoordinatorCommunicationContext) JobCoordinatorMetadataManager(org.apache.samza.job.metadata.JobCoordinatorMetadataManager) StreamPartitionCountMonitorFactory(org.apache.samza.coordinator.StreamPartitionCountMonitorFactory) JobInfoServingContext(org.apache.samza.coordinator.communication.JobInfoServingContext) JobConfig(org.apache.samza.config.JobConfig) StreamRegexMonitorFactory(org.apache.samza.coordinator.StreamRegexMonitorFactory) NamespaceAwareCoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.NamespaceAwareCoordinatorStreamStore) CoordinatorCommunication(org.apache.samza.coordinator.communication.CoordinatorCommunication) HttpCoordinatorToWorkerCommunicationFactory(org.apache.samza.coordinator.communication.HttpCoordinatorToWorkerCommunicationFactory) JobRestartSignalFactory(org.apache.samza.coordinator.lifecycle.JobRestartSignalFactory) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) JobRestartSignalFactoryContext(org.apache.samza.coordinator.lifecycle.JobRestartSignalFactoryContext) StartpointManager(org.apache.samza.startpoint.StartpointManager) JobModelHelper(org.apache.samza.coordinator.JobModelHelper) JobRestartSignal(org.apache.samza.coordinator.lifecycle.JobRestartSignal) SystemAdmins(org.apache.samza.system.SystemAdmins) ChangelogStreamManager(org.apache.samza.storage.ChangelogStreamManager)

Aggregations

StreamMetadataCache (org.apache.samza.system.StreamMetadataCache)13 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)5 SystemAdmins (org.apache.samza.system.SystemAdmins)5 SystemStream (org.apache.samza.system.SystemStream)5 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)5 Map (java.util.Map)4 Partition (org.apache.samza.Partition)4 Config (org.apache.samza.config.Config)4 StorageConfig (org.apache.samza.config.StorageConfig)4 ContainerModel (org.apache.samza.job.model.ContainerModel)4 SystemStreamMetadata (org.apache.samza.system.SystemStreamMetadata)4 Set (java.util.Set)3 JobConfig (org.apache.samza.config.JobConfig)3 MapConfig (org.apache.samza.config.MapConfig)3 TaskConfig (org.apache.samza.config.TaskConfig)3 TaskName (org.apache.samza.container.TaskName)3 TaskModel (org.apache.samza.job.model.TaskModel)3 SystemClock (org.apache.samza.util.SystemClock)3 File (java.io.File)2