// lame way to communicate with the coprocessor,
 // since it is loaded by a different class loader
 @Override
 public void prePut(
     final ObserverContext<RegionCoprocessorEnvironment> c,
     final Put put,
     final WALEdit edit,
     final Durability durability)
     throws IOException {
   if (put.getAttribute("ttl") != null) {
     Cell cell = put.getFamilyCellMap().values().iterator().next().get(0);
     KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
     ttls.put(TableName.valueOf(kv.getQualifier()), Bytes.toLong(kv.getValue()));
     c.bypass();
   } else if (put.getAttribute("versions") != null) {
     Cell cell = put.getFamilyCellMap().values().iterator().next().get(0);
     KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
     versions.put(TableName.valueOf(kv.getQualifier()), Bytes.toInt(kv.getValue()));
     c.bypass();
   }
 }
 @Override
 public void prePut(
     ObserverContext<RegionCoprocessorEnvironment> e,
     Put put,
     WALEdit edit,
     Durability durability)
     throws IOException {
   Region region = e.getEnvironment().getRegion();
   if (!region.getRegionInfo().isMetaTable()
       && !region.getRegionInfo().getTable().isSystemTable()) {
     if (put.getAttribute(TEST_ATR_KEY) != null) {
       LOG.debug("allow any put to happen " + region.getRegionInfo().getRegionNameAsString());
     } else {
       e.bypass();
     }
   }
 }
示例#3
0
    @Override
    public void prePut(
        final ObserverContext<RegionCoprocessorEnvironment> e,
        final Put put,
        final WALEdit edit,
        final Durability durability)
        throws IOException {
      byte[] attribute = put.getAttribute("visibility");
      byte[] cf = null;
      List<Cell> updatedCells = new ArrayList<Cell>();
      if (attribute != null) {
        for (List<? extends Cell> edits : put.getFamilyCellMap().values()) {
          for (Cell cell : edits) {
            KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
            if (cf == null) {
              cf = kv.getFamily();
            }
            Tag tag = new Tag(TAG_TYPE, attribute);
            List<Tag> tagList = new ArrayList<Tag>();
            tagList.add(tag);

            KeyValue newKV =
                new KeyValue(
                    kv.getRow(),
                    0,
                    kv.getRowLength(),
                    kv.getFamily(),
                    0,
                    kv.getFamilyLength(),
                    kv.getQualifier(),
                    0,
                    kv.getQualifierLength(),
                    kv.getTimestamp(),
                    KeyValue.Type.codeToType(kv.getType()),
                    kv.getValue(),
                    0,
                    kv.getValueLength(),
                    tagList);
            ((List<Cell>) updatedCells).add(newKV);
          }
        }
        put.getFamilyCellMap().remove(cf);
        // Update the family map
        put.getFamilyCellMap().put(cf, updatedCells);
      }
    }