ThemisMasterObserver extends BaseMasterObserver { public void setExpiredTsToZk(long currentExpiredTs) throws Exception { ZKUtil.createSetData(zk, themisExpiredTsZNodePath, Bytes.toBytes(String.valueOf(currentExpiredTs))); LOG.info("successfully set currentExpiredTs to zk, currentExpiredTs=" + currentExpiredTs + ", zkPath=" + themisExpiredTsZNodePath); }  @Override void start(CoprocessorEnvironment ctx); @Override void stop(CoprocessorEnvironment ctx); @Override void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
      HTableDescriptor desc, HRegionInfo[] regions); @Override void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
      List<HTableDescriptor> descriptors); static boolean isThemisEnableFamily(HColumnDescriptor desc); static boolean isThemisEnableTable(HTableDescriptor desc); static List<String> getThemisTables(HConnection connection); static String getThemisExpiredTsZNodePath(ZooKeeperWatcher zk); static long getThemisExpiredTsFromZk(ZooKeeperWatcher zk); static long getThemisExpiredTsFromZk(ZooKeeperWatcher zk, String path); void setExpiredTsToZk(long currentExpiredTs); void cleanLockBeforeTimestamp(long ts); static final String RETURNED_THEMIS_TABLE_DESC; static final String THEMIS_ENABLE_KEY; static final String THEMIS_EXPIRED_TIMESTAMP_CALCULATE_PERIOD_KEY; static final String THEMIS_EXPIRED_DATA_CLEAN_ENABLE_KEY; static final String THEMIS_EXPIRED_TIMESTAMP_ZNODE_NAME; }
@Test public void testSetExpiredTsToZk() throws Exception { long ts = System.currentTimeMillis() - 10l * 86400 * 1000; ThemisMasterObserver masterObserver = new ThemisMasterObserver(); masterObserver.zk = new ZooKeeperWatcher(conf, "test", null, true); masterObserver.themisExpiredTsZNodePath = ThemisMasterObserver.getThemisExpiredTsZNodePath(masterObserver.zk); masterObserver.setExpiredTsToZk(ts); Assert.assertEquals(ts, ThemisMasterObserver.getThemisExpiredTsFromZk(masterObserver.zk)); Assert.assertEquals(Long.MIN_VALUE, ThemisMasterObserver.getThemisExpiredTsFromZk(masterObserver.zk, masterObserver.themisExpiredTsZNodePath + "/" + System.currentTimeMillis())); masterObserver.zk.close(); }