Search in sources :

Example 1 with ImmutableTriple

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;
    }
}
Also used : ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) ConsumerConnector(kafka.javaapi.consumer.ConsumerConnector)

Example 2 with ImmutableTriple

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);
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) MutableLockedInodePath(alluxio.master.file.meta.MutableLockedInodePath) LockedInodePath(alluxio.master.file.meta.LockedInodePath) SetAndRestoreAuthenticatedUser(alluxio.SetAndRestoreAuthenticatedUser) Mode(alluxio.security.authorization.Mode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with ImmutableTriple

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());
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TreeSet(java.util.TreeSet) ConfigProperty(alluxio.grpc.ConfigProperty) MasterWebUIConfiguration(alluxio.wire.MasterWebUIConfiguration) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with ImmutableTriple

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());
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) WorkerWebUIConfiguration(alluxio.wire.WorkerWebUIConfiguration) TreeSet(java.util.TreeSet) ConfigProperty(alluxio.grpc.ConfigProperty) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 5 with ImmutableTriple

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));
    }
}
Also used : Serializable(java.io.Serializable) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) Attribute(ddf.catalog.data.Attribute) AttributeType(ddf.catalog.data.AttributeType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl)

Aggregations

ImmutableTriple (org.apache.commons.lang3.tuple.ImmutableTriple)17 Triple (org.apache.commons.lang3.tuple.Triple)12 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 LockedInodePath (alluxio.master.file.meta.LockedInodePath)4 SetAndRestoreAuthenticatedUser (alluxio.SetAndRestoreAuthenticatedUser)3 MutableLockedInodePath (alluxio.master.file.meta.MutableLockedInodePath)3 Mode (alluxio.security.authorization.Mode)3 List (java.util.List)3 ConfigProperty (alluxio.grpc.ConfigProperty)2 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)2 Sha256Hash (co.rsk.bitcoinj.core.Sha256Hash)2 StoredBlock (co.rsk.bitcoinj.core.StoredBlock)2 TIntList (gnu.trove.list.TIntList)2 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 InputStream (java.io.InputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 BigInteger (java.math.BigInteger)2 LinkedList (java.util.LinkedList)2 TreeSet (java.util.TreeSet)2