use of org.apache.commons.lang3.tuple.ImmutableTriple in project pinot by linkedin.
the class KafkaConsumerManager method acquireConsumerAndIteratorForConfig.
public static ConsumerAndIterator acquireConsumerAndIteratorForConfig(KafkaHighLevelStreamProviderConfig config) {
final ImmutableTriple<String, String, String> configKey = new ImmutableTriple<>(config.getTopicName(), config.getGroupId(), config.getZkString());
synchronized (KafkaConsumerManager.class) {
// If we have the consumer and it's not already acquired, return it, otherwise error out if it's already acquired
if (CONSUMER_AND_ITERATOR_FOR_CONFIG_KEY.containsKey(configKey)) {
ConsumerAndIterator consumerAndIterator = CONSUMER_AND_ITERATOR_FOR_CONFIG_KEY.get(configKey);
if (CONSUMER_RELEASE_TIME.get(consumerAndIterator).equals(IN_USE)) {
throw new RuntimeException("Consumer/iterator " + consumerAndIterator.getId() + " already in use!");
} else {
LOGGER.info("Reusing kafka consumer/iterator with id {}", consumerAndIterator.getId());
CONSUMER_RELEASE_TIME.put(consumerAndIterator, IN_USE);
return consumerAndIterator;
}
}
LOGGER.info("Creating new kafka consumer and iterator for topic {}", config.getTopicName());
// Create the consumer
ConsumerConnector consumer = kafka.consumer.Consumer.createJavaConsumerConnector(config.getKafkaConsumerConfig());
// Create the iterator (can only be done once per consumer)
ConsumerIterator<byte[], byte[]> iterator = consumer.createMessageStreams(config.getTopicMap(1)).get(config.getTopicName()).get(0).iterator();
// Mark both the consumer and iterator as acquired
ConsumerAndIterator consumerAndIterator = new ConsumerAndIterator(consumer, iterator);
CONSUMER_AND_ITERATOR_FOR_CONFIG_KEY.put(configKey, consumerAndIterator);
CONSUMER_RELEASE_TIME.put(consumerAndIterator, IN_USE);
LOGGER.info("Created consumer/iterator with id {} for topic {}", consumerAndIterator.getId(), config.getTopicName());
return consumerAndIterator;
}
}
use of org.apache.commons.lang3.tuple.ImmutableTriple in project alluxio by Alluxio.
the class PermissionCheckTest method getPermissionOwner.
@Test
public void getPermissionOwner() throws Exception {
ArrayList<Triple<String, String, Mode>> permissions = new ArrayList<>();
permissions.add(new ImmutableTriple<>(TEST_USER_1.getUser(), TEST_USER_1.getGroup(), new Mode((short) 0754)));
LockedInodePath lockedInodePath = getLockedInodePath(permissions);
try (SetAndRestoreAuthenticatedUser u = new SetAndRestoreAuthenticatedUser(TEST_USER_1.getUser())) {
PermissionChecker checker = new PermissionChecker(mInodeTree);
Mode.Bits actual = checker.getPermission(lockedInodePath);
Assert.assertEquals(Mode.Bits.ALL, actual);
}
}
use of org.apache.commons.lang3.tuple.ImmutableTriple in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandler method getWebUIConfiguration.
/**
* Gets Web UI ServerConfiguration page data.
*
* @return the response object
*/
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
return RestUtils.call(() -> {
MasterWebUIConfiguration response = new MasterWebUIConfiguration();
response.setWhitelist(mFileSystemMaster.getWhiteList());
TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.MASTER_WHITELIST.toString());
for (ConfigProperty configProperty : mMetaMaster.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
String confName = configProperty.getName();
if (!alluxioConfExcludes.contains(confName)) {
sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
}
}
response.setConfiguration(sortedProperties);
return response;
}, ServerConfiguration.global());
}
use of org.apache.commons.lang3.tuple.ImmutableTriple in project alluxio by Alluxio.
the class AlluxioWorkerRestServiceHandler method getWebUIConfiguration.
/**
* Gets Web UI ServerConfiguration page data.
*
* @return the response object
*/
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
return RestUtils.call(() -> {
WorkerWebUIConfiguration response = new WorkerWebUIConfiguration();
response.setWhitelist(mBlockWorker.getWhiteList());
TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.WORKER_WHITELIST.toString());
for (ConfigProperty configProperty : mBlockWorker.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
String confName = configProperty.getName();
if (!alluxioConfExcludes.contains(confName)) {
sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
}
}
response.setConfiguration(sortedProperties);
return response;
}, ServerConfiguration.global());
}
use of org.apache.commons.lang3.tuple.ImmutableTriple in project ddf by codice.
the class CsvTransformerTest method buildMetacardDataMap.
private void buildMetacardDataMap() {
for (ImmutableTriple entry : ATTRIBUTE_DATA) {
String attributeName = (String) entry.getLeft();
Serializable attributeValue = (Serializable) entry.getMiddle();
AttributeType attributeType = (AttributeType) entry.getRight();
Attribute attribute = new AttributeImpl(attributeName, attributeValue);
metacardDataMap.put(attributeName, attribute);
ATTRIBUTE_DESCRIPTOR_LIST.add(buildAttributeDescriptor(attributeName, attributeType));
}
}
Aggregations