Search in sources :

Example 6 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider in project sling by apache.

the class CassandraDataAddLoadTest method testAddLoadTestData.

public void testAddLoadTestData() {
    try {
        for (int k = 0; k < sizes.length; k++) {
            CassandraResourceProvider cassandraResourceProvider = new CassandraResourceProvider();
            createColumnFamily(cfs[k], cassandraResourceProvider.getKeyspace(), new StringSerializer());
            cassandraResourceProvider.setColumnFamily(cfs[k]);
            CassandraResourceResolver resolver = new CassandraResourceResolver();
            for (int i = 0; i < sizes[k]; i++) {
                String path = parentPath + cfs[k] + "/" + i;
                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("metadata", "resolutionPathInfo=json");
                map1.put("resourceType", "nt:cassandra0");
                map1.put("resourceSuperType", "nt:supercass1");
                cassandraResourceProvider.create(resolver, path, map1);
                cassandraResourceProvider.commit(resolver);
                System.out.println(">>" + path);
            }
        }
    } 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)

Example 7 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider 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 8 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider 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 9 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider 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 10 with CassandraResourceProvider

use of org.apache.sling.cassandra.resource.provider.CassandraResourceProvider 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)

Aggregations

HInvalidRequestException (me.prettyprint.hector.api.exceptions.HInvalidRequestException)10 CassandraResourceProvider (org.apache.sling.cassandra.resource.provider.CassandraResourceProvider)10 StringSerializer (me.prettyprint.cassandra.serializers.StringSerializer)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 Test (org.junit.Test)8 HashMap (java.util.HashMap)4 CassandraResourceResolver (org.apache.sling.cassandra.resource.provider.CassandraResourceResolver)4 HashSet (java.util.HashSet)1