@Override public MetricRegistry getMetricRegistry() { return env.getSharedResources().getMetricRegistry(); }
GcTimestampTracker() throws Exception { this.curator = env.getSharedResources().getCurator(); }
public CommitData createCommitData() { CommitData cd = new CommitData(); cd.cw = env.getSharedResources().getConditionalWriter(); cd.bulkCw = env.getSharedResources().getBulkConditionalWriter(); return cd; }
@Override public void setWeakNotification(Bytes row, Column col) { checkIfOpen(); Preconditions.checkNotNull(row); Preconditions.checkNotNull(col); if (!env.getWeakObservers().containsKey(col)) { throw new IllegalArgumentException("Column not configured for weak notifications " + col); } env.getSharedResources().getVisCache().validate(col); Set<Column> columns = weakNotifications.get(row); if (columns == null) { columns = new HashSet<>(); weakNotifications.put(row, columns); } columns.add(col); }
private void writeWeakNotifications(long commitTs) { if (weakNotifications.size() > 0) { SharedBatchWriter sbw = env.getSharedResources().getBatchWriter(); ArrayList<Mutation> mutations = new ArrayList<>(); for (Entry<Bytes, Set<Column>> entry : weakNotifications.entrySet()) { Flutation m = new Flutation(env, entry.getKey()); for (Column col : entry.getValue()) { Notification.put(env, m, col, commitTs); } mutations.add(m); } sbw.writeMutations(mutations); } }
private Stamp getTimestamp() { return env.getSharedResources().getOracleClient().getStamp(); }
private static Stamp allocateTimestamp(Environment env) { return env.getSharedResources().getTimestampTracker().allocateTimestamp(); }
@Override public Map<Bytes, Map<Column, Bytes>> get(Collection<Bytes> rows, Set<Column> columns) { checkIfOpen(); if (rows.size() == 0 || columns.size() == 0) { return Collections.emptyMap(); } env.getSharedResources().getVisCache().validate(columns); ParallelSnapshotScanner pss = new ParallelSnapshotScanner(rows, columns, env, startTs, stats); Map<Bytes, Map<Column, Bytes>> ret = pss.scan(); for (Entry<Bytes, Map<Column, Bytes>> entry : ret.entrySet()) { updateColumnsRead(entry.getKey(), entry.getValue().keySet()); } return ret; }
void deleteWeakRow() { if (weakNotification != null) { env.getSharedResources().getBatchWriter() .writeMutation(weakNotification.newDelete(env, startTs)); } }
private synchronized void close(boolean checkForStaleScan) { if (status != TxStatus.CLOSED) { status = TxStatus.CLOSED; if (checkForStaleScan && !commitAttempted) { Stamp stamp = env.getSharedResources().getOracleClient().getStamp(); if (startTs < stamp.getGcTimestamp()) { throw new StaleScanException(); } } env.getSharedResources().getTimestampTracker().removeTimestamp(startTs); } }
@Override public void commit() { super.commit(); // wait for any async mutations that transaction write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); } };
/** * Retrieves transactor ID by first getting/creating transactor (which is only done until * necessary) */ private Long getTransactorID() { if (tnode == null) { tnode = env.getSharedResources().getTransactorNode(); } return tnode.getTransactorID().getLongID(); }
private void createZkNode(long ts) { Preconditions.checkState(node == null, "expected node to be null"); node = new PersistentEphemeralNode(env.getSharedResources().getCurator(), Mode.EPHEMERAL, getNodePath(), LongUtil.toByteArray(ts)); CuratorUtil.startAndWait(node, 10); zkTimestamp = ts; }
/** * Creates a transactor node using given transactor id * * @param env Environment * @param tid Transactor ID used to create node */ public TransactorNode(Environment env, TransactorID tid) { this.env = env; this.tid = tid; node = new PersistentEphemeralNode(env.getSharedResources().getCurator(), Mode.EPHEMERAL, getNodePath(), tid.toString().getBytes()); CuratorUtil.startAndWait(node, 10); status = TrStatus.OPEN; }
public OracleClient(Environment env) { this.env = env; responseTimer = MetricsUtil.getTimer(env.getConfiguration(), env.getSharedResources().getMetricRegistry(), env.getMetricNames().getOracleResponseTime()); stampsHistogram = MetricsUtil.getHistogram(env.getConfiguration(), env.getSharedResources() .getMetricRegistry(), env.getMetricNames().getOracleClientStamps()); timestampRetriever = new TimestampRetriever(); thread = new Thread(timestampRetriever); thread.setDaemon(true); thread.start(); }
public OracleServer(Environment env) throws Exception { this.env = env; stampsHistogram = MetricsUtil.getHistogram(env.getConfiguration(), env.getSharedResources() .getMetricRegistry(), env.getMetricNames().getOracleServerStamps()); this.cnxnListener = new CuratorCnxnListener(); this.maxTsPath = ZookeeperPath.ORACLE_MAX_TIMESTAMP; this.oraclePath = ZookeeperPath.ORACLE_SERVER; }
public static void put(Environment env, Mutation m, Column col, long ts) { ColumnVisibility cv = env.getSharedResources().getVisCache().getCV(col); m.put(ColumnConstants.NOTIFY_CF.toArray(), encodeCol(col), cv, encodeTs(ts, false), TransactionImpl.EMPTY); }
public FluoCondition(Environment env, Column col) { super(ByteUtil.toByteSequence(col.getFamily()), ByteUtil.toByteSequence(col.getQualifier())); if (col.getVisibility().length() > 0) { setVisibility(env.getSharedResources().getVisCache().getCV(col)); } }
public Flutation newDelete(Environment env, long ts) { Flutation m = new Flutation(env, getRow()); ColumnVisibility cv = env.getSharedResources().getVisCache().getCV(getColumn()); m.put(ColumnConstants.NOTIFY_CF.toArray(), encodeCol(getColumn()), cv, encodeTs(ts, true), TransactionImpl.EMPTY); return m; }
public static void put(Environment env, Mutation m, Column col, long ts, byte[] val) { ColumnVisibility cv; if (env != null) { cv = env.getSharedResources().getVisCache().getCV(col.getVisibility()); } else if (col.getVisibility().length() == 0) { cv = VisibilityCache.EMPTY_VIS; } else { cv = new ColumnVisibility(ByteUtil.toText(col.getVisibility())); } m.put(ByteUtil.toText(col.getFamily()), ByteUtil.toText(col.getQualifier()), cv, ts, new Value( val)); } }