Ejemplo n.º 1
0
  @Override
  public PersistenceObject load(
      PersistenceManagementEvent persistenceManagementEvent, String nodeId) {

    List<NodeSnapshot> list = new ArrayList<NodeSnapshot>();

    ColumnSlice<String, byte[]> cs;

    SliceQuery<String, String, byte[]> q = HFactory.createSliceQuery(keyspace, sser, sser, bser);
    q.setColumnFamily(COLUMN_FAMILY_NAME)
        .setKey(persistenceManagementEvent.getRevision())
        .setRange("", "", false, 1000)
        .setColumnNames(nodeId);

    QueryResult<ColumnSlice<String, byte[]>> r = q.execute();

    cs = r.get();
    PersistenceObject persistenceObject = null;
    for (HColumn<String, byte[]> hc : cs.getColumns()) {
      persistenceObject = (PersistenceObject) ByteSerializer.BToO(hc.getValue());
      //            list.add(new NodeSnapshot(hc.getName(), hc.getValue()));
    }
    //        return list;
    return persistenceObject;
  }
Ejemplo n.º 2
0
 @Override
 public void save(
     PersistenceManagementEvent persistenceManagementEvent,
     String nodeID,
     PersistenceObject persistenceObject) {
   Mutator<String> mutator = HFactory.createMutator(keyspace, sser);
   mutator.insert(
       persistenceManagementEvent.getRevision(),
       COLUMN_FAMILY_NAME,
       HFactory.createColumn(nodeID, ByteSerializer.OToB(persistenceObject), sser, bser));
   mutator.insert(
       persistenceManagementEvent.getExecutionPlanIdentifier(),
       INDEX_COLUMN_FAMILY_NAME,
       HFactory.createColumn(
           persistenceManagementEvent.getRevision(),
           String.valueOf(System.currentTimeMillis()),
           sser,
           sser));
   mutator.execute();
 }