use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraResourceProvider method insertResource.
private boolean insertResource(String path, Map map) throws PersistenceException {
try {
String r = getrowID(path);
if (r == null) {
return false;
}
String _cf = CassandraResourceProviderUtil.getColumnFamilySector(path);
createColumnFamily(_cf, this.getKeyspace(), new StringSerializer());
String metadata = map.get("metadata") == null ? "resolutionPathInfo=json" : (String) map.get("metadata");
String resourceType = map.get("resourceType") == null ? "nt:cassandra" : (String) map.get("resourceType");
String resourceSuperType = map.get("resourceSuperType") == null ? "nt:superCassandra" : (String) map.get("resourceSuperType");
addData(this.getKeyspace(), _cf, new StringSerializer(), new String[] { "'" + r + "','" + path + "','" + resourceType + "','" + resourceSuperType + "','" + metadata + "'" });
} catch (NoSuchAlgorithmException e) {
throw new PersistenceException(e.getMessage());
} catch (UnsupportedEncodingException e) {
throw new PersistenceException(e.getMessage());
}
return true;
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraResourceProviderUtil method isResourceExists.
public static boolean isResourceExists(CassandraResourceProvider resourceProvider, Keyspace keyspace, String path) throws Exception {
String cql = resourceProvider.getCassandraMapperMap().get(CassandraResourceProviderUtil.getColumnFamilySector(path)).getCQL(CassandraResourceProviderUtil.getColumnFamilySector(path), CassandraResourceProviderUtil.getRemainingPath(path));
QueryResult<CqlRows<String, String, String>> result = CassandraResourceProviderUtil.executeQuery(cql, keyspace, new StringSerializer());
return recordExists(result, "policy");
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraDataAddTest method testAddData.
@Test
public void testAddData() {
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'" });
Assert.assertTrue(true);
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraDataParentNodeTest method testGetParentData.
@Test
public void testGetParentData() {
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'" });
getParentData(cassandraResourceProvider, cf);
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraModifyResourceProviderDeleteTest method testDeleteData.
@Test
public void testDeleteData() {
String cf = "p3";
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));
cassandraResourceProvider.delete(resolver, path1);
Assert.assertNotNull("Uncommited deleted resource cannot be null", cassandraResourceProvider.getResource(resolver, path1));
cassandraResourceProvider.commit(resolver);
Assert.assertNull("Deleted resource should be null", cassandraResourceProvider.getResource(resolver, path1));
} catch (Exception e) {
LOGGER.info("Ignore err" + e.getMessage());
Assert.fail("Failed to add data to cassandra");
}
}
Aggregations