use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraResource method loadResourceData.
private void loadResourceData(ResourceProvider resourceProvider) {
CassandraResourceProvider cassandraResourceProvider = (CassandraResourceProvider) resourceProvider;
try {
// TODO ColumnFamilySector is NULL and hence this..
String cql = cassandraResourceProvider.getCassandraMapperMap().get(columnFamilySector).getCQL(columnFamilySector, remainingPath);
QueryResult<CqlRows<String, String, String>> results = CassandraResourceProviderUtil.executeQuery(cql, ((CassandraResourceProvider) resourceProvider).getKeyspace(), new StringSerializer());
populateDataFromResult(results);
dataLoaded = true;
} catch (CassandraMapperException e) {
System.out.println("Error occurred from resource at " + resourcePath + " : " + e.getMessage());
LOGGER.error("Error occurred from resource at " + resourcePath + " : " + e.getMessage());
}
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class CassandraResourceProvider method deleteResource.
private boolean deleteResource(ResourceResolver resourceResolver, String path) throws PersistenceException {
try {
String key = getrowID(path);
if (key == null) {
return false;
}
String _cf = CassandraResourceProviderUtil.getColumnFamilySector(path);
createColumnFamily(_cf, this.getKeyspace(), new StringSerializer());
StringSerializer se = new StringSerializer();
CqlQuery<String, String, String> cqlQuery = new CqlQuery<String, String, String>(keyspace, se, se, se);
String query = "delete FROM " + _cf + " where KEY = '" + key + "';";
cqlQuery.setQuery(query);
QueryResult<CqlRows<String, String, String>> result = cqlQuery.execute();
} 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 AccessControlUtil method updateACL.
private void updateACL(String rid, String policy, StringSerializer se, QueryResult<CqlRows<String, String, String>> results) {
String oldACL = "";
for (Row<String, String, String> row : ((CqlRows<String, String, String>) results.get()).getList()) {
for (HColumn column : row.getColumnSlice().getColumns()) {
if ("policy".equalsIgnoreCase(column.getName().toString()) && column.getValue() != null) {
oldACL = column.getValue().toString();
}
}
}
if (!oldACL.isEmpty()) {
oldACL = oldACL + ";" + policy;
}
addACL(rid, oldACL, new StringSerializer());
}
use of me.prettyprint.cassandra.serializers.StringSerializer in project sling by apache.
the class AccessControlUtil method getACL.
private String[] getACL(String path) throws Exception {
if (getCassandraSystemNodeACL(path) != null) {
return getCassandraSystemNodeACL(path);
}
String rid = getrowID(path);
createColumnFamily(ACL_CF, provider.getKeyspace(), new StringSerializer());
String getAllACEs = "select * from " + ACL_CF + " where KEY = '" + rid + "'";
QueryResult<CqlRows<String, String, String>> results = CassandraResourceProviderUtil.executeQuery(getAllACEs, provider.getKeyspace(), new StringSerializer());
String policy = null;
for (Row<String, String, String> row : ((CqlRows<String, String, String>) results.get()).getList()) {
for (HColumn column : row.getColumnSlice().getColumns()) {
if ("policy".equalsIgnoreCase(column.getName().toString()) && column.getValue() != null) {
policy = column.getValue().toString();
}
}
}
return policy != null ? policy.split(";") : null;
}
use of me.prettyprint.cassandra.serializers.StringSerializer 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");
}
}
Aggregations