org.apache.flink.shaded.guava18.com.google.common.collect.Iterators Java Examples

The following examples show how to use org.apache.flink.shaded.guava18.com.google.common.collect.Iterators. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricRegistryImplTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testReporterIntervalParsingErrorFallsBackToDefaultValue() throws Exception {
	MetricConfig config = new MetricConfig();
	// in a prior implementation the time amount was applied even if the time unit was invalid
	// in this case this would imply using 1 SECOND as the interval (seconds is the default)
	config.setProperty(ConfigConstants.METRICS_REPORTER_INTERVAL_SUFFIX, "1 UNICORN");

	final ManuallyTriggeredScheduledExecutorService manuallyTriggeredScheduledExecutorService = new ManuallyTriggeredScheduledExecutorService();

	MetricRegistryImpl registry = new MetricRegistryImpl(
		MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
		Collections.singletonList(ReporterSetup.forReporter("test", config, new TestReporter3())),
		manuallyTriggeredScheduledExecutorService);
	try {
		Collection<ScheduledFuture<?>> scheduledTasks = manuallyTriggeredScheduledExecutorService.getScheduledTasks();
		ScheduledFuture<?> reportTask = Iterators.getOnlyElement(scheduledTasks.iterator());
		Assert.assertEquals(MetricOptions.REPORTER_INTERVAL.defaultValue().getSeconds(), reportTask.getDelay(TimeUnit.SECONDS));
	} finally {
		registry.shutdown().get();
	}
}
 
Example #2
Source File: PluginManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Returns in iterator over all available implementations of the given service interface (SPI) in all the plugins
 * known to this plugin manager instance.
 *
 * @param service the service interface (SPI) for which implementations are requested.
 * @param <P> Type of the requested plugin service.
 * @return Iterator over all implementations of the given service that could be loaded from all known plugins.
 */
public <P extends Plugin> Iterator<P> load(Class<P> service) {
	ArrayList<Iterator<P>> combinedIterators = new ArrayList<>(pluginDescriptors.size());
	for (PluginDescriptor pluginDescriptor : pluginDescriptors) {
		PluginLoader pluginLoader = PluginLoader.create(pluginDescriptor, parentClassLoader, alwaysParentFirstPatterns);
		combinedIterators.add(pluginLoader.load(service));
	}
	return Iterators.concat(combinedIterators.iterator());
}
 
Example #3
Source File: DefaultPluginManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public <P> Iterator<P> load(Class<P> service) {
	ArrayList<Iterator<P>> combinedIterators = new ArrayList<>(pluginDescriptors.size());
	for (PluginDescriptor pluginDescriptor : pluginDescriptors) {
		PluginLoader pluginLoader = PluginLoader.create(pluginDescriptor, parentClassLoader, alwaysParentFirstPatterns);
		combinedIterators.add(pluginLoader.load(service));
	}
	return Iterators.concat(combinedIterators.iterator());
}
 
Example #4
Source File: ReporterSetup.java    From flink with Apache License 2.0 5 votes vote down vote up
private static Iterator<MetricReporterFactory> getAllReporterFactories(@Nullable PluginManager pluginManager) {
	final Iterator<MetricReporterFactory> factoryIteratorSPI = ServiceLoader.load(MetricReporterFactory.class).iterator();
	final Iterator<MetricReporterFactory> factoryIteratorPlugins = pluginManager != null
		? pluginManager.load(MetricReporterFactory.class)
		: Collections.emptyIterator();

	return Iterators.concat(factoryIteratorPlugins, factoryIteratorSPI);
}
 
Example #5
Source File: CoordinatorEventsExactlyOnceITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
static StreamStateHandle readSnapshot(TaskStateManager stateManager, OperatorID operatorId) {
	final PrioritizedOperatorSubtaskState poss = stateManager.prioritizedOperatorState(operatorId);
	if (!poss.isRestored()) {
		return null;
	}

	final StateObjectCollection<OperatorStateHandle> opState =
		stateManager.prioritizedOperatorState(operatorId).getPrioritizedManagedOperatorState().get(0);
	final OperatorStateHandle handle = Iterators.getOnlyElement(opState.iterator());
	return handle.getDelegateStateHandle();
}
 
Example #6
Source File: JsonUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public java.util.Iterator<Object> iterator() {
	return Iterators.forArray(toArray());
}
 
Example #7
Source File: JsonUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public java.util.Iterator<Object> iterator() {
	return Iterators.forArray(toArray());
}