Search in sources :

Example 16 with StringSerializer

use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.

the class CassandraDataChildNodeTest method testGetChildrenData.

@Test
public void testGetChildrenData() {
    String cf = "p1";
    try {
        String r1 = getrowID("/content/cassandra/" + cf + "/c1");
        String r2 = getrowID("/content/cassandra/" + cf + "/c1/c2");
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        addData(cassandraResourceProvider.getKeyspace(), cf, new StringSerializer(), new String[] { "'" + r1 + "','/content/cassandra/" + cf + "/c1','nt:cassandra1','nt:supercass1','resolutionPathInfo=json'", "'" + r2 + "','/content/cassandra/" + cf + "/c1/c2','nt:cassandra','nt:supercass2','resolutionPathInfo=json'" });
        getChildrenData(cassandraResourceProvider, cf);
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 17 with StringSerializer

use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.

the class CassandraDataChildNodeIterableTest method testGetChildrenData.

@Test
public void testGetChildrenData() {
    String cf = "p1";
    try {
        String r1 = getrowID("/content/cassandra/" + cf + "/c1");
        String r2 = getrowID("/content/cassandra/" + cf + "/c1/c2");
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        addData(cassandraResourceProvider.getKeyspace(), cf, new StringSerializer(), new String[] { "'" + r1 + "','/content/cassandra/" + cf + "/c1','nt:cassandra1','nt:supercass1','resolutionPathInfo=json'", "'" + r2 + "','/content/cassandra/" + cf + "/c1/c2','nt:cassandra','nt:supercass2','resolutionPathInfo=json'" });
        getChildrenData(cassandraResourceProvider, cf);
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 18 with StringSerializer

use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.

the class CassandraDataReadTest method testReadData.

@Test
public void testReadData() {
    String cf = "p1";
    try {
        String r1 = getrowID("/content/cassandra/" + cf + "/c1");
        String r2 = getrowID("/content/cassandra/" + cf + "/c1/c2");
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        addData(cassandraResourceProvider.getKeyspace(), cf, new StringSerializer(), new String[] { "'" + r1 + "','/content/cassandra/" + cf + "/c1','nt:cassandra1','nt:supercass1','resolutionPathInfo=json'", "'" + r2 + "','/content/cassandra/" + cf + "/c1/c2','nt:cassandra','nt:supercass2','resolutionPathInfo=json'" });
        readData(cassandraResourceProvider, cf);
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
    }
}
Also used : CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 19 with StringSerializer

use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.

the class CassandraModifyResourceProviderAddTest method testAddData.

@Test
public void testAddData() {
    String cf = "p2";
    try {
        String path1 = "/content/cassandra/" + cf + "/c1";
        CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
        createColumnFamily(cf, cassandraResourceProvider.getKeyspace(), new StringSerializer());
        cassandraResourceProvider.setColumnFamily(cf);
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("metadata", "resolutionPathInfo=json");
        map1.put("resourceType", "nt:cassandra0");
        map1.put("resourceSuperType", "nt:supercass1");
        CassandraResourceResolver resolver = new CassandraResourceResolver();
        cassandraResourceProvider.create(resolver, path1, map1);
        Assert.assertNull("Before Commiting Resource should be null", cassandraResourceProvider.getResource(resolver, path1));
        cassandraResourceProvider.commit(resolver);
        Assert.assertNotNull("Commited Resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
    } catch (Exception e) {
        LOGGER.info("Ignore err" + e.getMessage());
        Assert.fail("Failed to add data to cassandra");
    }
}
Also used : HashMap(java.util.HashMap) CassandraResourceProvider(org.apache.sling.cassandra.resource.provider.CassandraResourceProvider) StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer) HInvalidRequestException(me.prettyprint.hector.api.exceptions.HInvalidRequestException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CassandraResourceResolver(org.apache.sling.cassandra.resource.provider.CassandraResourceResolver) Test(org.junit.Test)

Example 20 with StringSerializer

use of me.prettyprint.cassandra.serializers.StringSerializer in project cassandra-indexing by hmsonline.

the class AbstractIndexingTest method delete.

protected void delete(Keyspace keyspace, String columnFamily, String rowKey, String... columnNames) throws Exception {
    StringSerializer serializer = StringSerializer.get();
    Mutator<String> mutator = HFactory.createMutator(keyspace, serializer);
    for (String columnName : columnNames) {
        mutator.addDeletion(rowKey, columnFamily, columnName, serializer);
    }
    mutator.execute();
}
Also used : StringSerializer(me.prettyprint.cassandra.serializers.StringSerializer)

Aggregations

StringSerializer (me.prettyprint.cassandra.serializers.StringSerializer)21 HInvalidRequestException (me.prettyprint.hector.api.exceptions.HInvalidRequestException)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 CassandraResourceProvider (org.apache.sling.cassandra.resource.provider.CassandraResourceProvider)9 Test (org.junit.Test)8 CqlRows (me.prettyprint.cassandra.model.CqlRows)6 HashMap (java.util.HashMap)5 CassandraResourceResolver (org.apache.sling.cassandra.resource.provider.CassandraResourceResolver)4 HColumn (me.prettyprint.hector.api.beans.HColumn)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 CqlQuery (me.prettyprint.cassandra.model.CqlQuery)1 OrderedRows (me.prettyprint.hector.api.beans.OrderedRows)1 Row (me.prettyprint.hector.api.beans.Row)1 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)1 Namespace (org.apache.archiva.metadata.repository.cassandra.model.Namespace)1 CassandraMapperException (org.apache.sling.cassandra.resource.provider.mapper.CassandraMapperException)1