Search in sources :

Example 11 with StringSerializer

use of voldemort.serialization.StringSerializer in project voldemort by voldemort.

the class VoldemortAdminTool method getMetadataVersionsForNode.

private static String getMetadataVersionsForNode(AdminClient adminClient, int nodeId) {
    List<Integer> partitionIdList = Lists.newArrayList();
    for (Node node : adminClient.getAdminClientCluster().getNodes()) {
        partitionIdList.addAll(node.getPartitionIds());
    }
    Iterator<Pair<ByteArray, Versioned<byte[]>>> entriesIterator = adminClient.bulkFetchOps.fetchEntries(nodeId, SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name(), partitionIdList, null, true);
    Serializer<String> serializer = new StringSerializer("UTF8");
    String keyObject = null;
    String valueObject = null;
    while (entriesIterator.hasNext()) {
        try {
            Pair<ByteArray, Versioned<byte[]>> kvPair = entriesIterator.next();
            byte[] keyBytes = kvPair.getFirst().get();
            byte[] valueBytes = kvPair.getSecond().getValue();
            keyObject = serializer.toObject(keyBytes);
            if (!keyObject.equals(SystemStoreConstants.VERSIONS_METADATA_KEY)) {
                continue;
            }
            valueObject = serializer.toObject(valueBytes);
        } catch (Exception e) {
            System.err.println("Error while retrieving Metadata versions from node : " + nodeId + ". Exception = \n");
            e.printStackTrace();
            System.exit(-1);
        }
    }
    return valueObject;
}
Also used : Versioned(voldemort.versioning.Versioned) Node(voldemort.cluster.Node) StoreNotFoundException(com.sleepycat.persist.StoreNotFoundException) DecoderException(org.apache.commons.codec.DecoderException) EOFException(java.io.EOFException) SerializationException(voldemort.serialization.SerializationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) InvalidMetadataException(voldemort.store.InvalidMetadataException) ByteArray(voldemort.utils.ByteArray) StringSerializer(voldemort.serialization.StringSerializer) Pair(voldemort.utils.Pair)

Example 12 with StringSerializer

use of voldemort.serialization.StringSerializer in project voldemort by voldemort.

the class AbstractStoreClientFactory method getRemoteMetadata.

protected List<Versioned<String>> getRemoteMetadata(String key, URI url) {
    Store<ByteArray, byte[], byte[]> remoteStore = getStore(MetadataStore.METADATA_STORE_NAME, url.getHost(), url.getPort(), this.requestFormatType);
    Store<String, String, byte[]> store = SerializingStore.wrap(remoteStore, new StringSerializer("UTF-8"), new StringSerializer("UTF-8"), new IdentitySerializer());
    return store.get(key, null);
}
Also used : ByteArray(voldemort.utils.ByteArray) IdentitySerializer(voldemort.serialization.IdentitySerializer) StringSerializer(voldemort.serialization.StringSerializer)

Example 13 with StringSerializer

use of voldemort.serialization.StringSerializer in project voldemort by voldemort.

the class ExternalSorterTest method testSorting.

public void testSorting(int threads) {
    ExternalSorter<String> sorter = new ExternalSorter<String>(new StringSerializer(), 10, threads);
    List<String> sorted = Lists.newArrayList(sorter.sorted(strings.iterator()));
    List<String> expected = new ArrayList<String>(strings);
    Collections.sort(expected);
    assertEquals(expected, sorted);
}
Also used : ArrayList(java.util.ArrayList) StringSerializer(voldemort.serialization.StringSerializer)

Aggregations

StringSerializer (voldemort.serialization.StringSerializer)13 ByteArray (voldemort.utils.ByteArray)9 Versioned (voldemort.versioning.Versioned)5 File (java.io.File)4 Test (org.junit.Test)4 IdentitySerializer (voldemort.serialization.IdentitySerializer)4 Node (voldemort.cluster.Node)3 VoldemortConfig (voldemort.server.VoldemortConfig)3 Pair (voldemort.utils.Pair)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Serializer (voldemort.serialization.Serializer)2 StorageConfiguration (voldemort.store.StorageConfiguration)2 StoreDefinition (voldemort.store.StoreDefinition)2 BdbStorageConfiguration (voldemort.store.bdb.BdbStorageConfiguration)2 SerializingStore (voldemort.store.serialized.SerializingStore)2 Props (voldemort.utils.Props)2 Database (com.sleepycat.je.Database)1 DatabaseConfig (com.sleepycat.je.DatabaseConfig)1