GcTimestampTracker() throws Exception { this.curator = env.getSharedResources().getCurator(); }
public void setAuthorizations(Authorizations auths) { this.auths = auths; // TODO the following is a big hack, this method is currently not exposed in API resources.close(); try { this.resources = new SharedResources(this); } catch (TableNotFoundException e) { throw new RuntimeException(e); } }
public SharedBatchWriter getBatchWriter() { checkIfClosed(); return sbw; }
public synchronized TimestampTracker getTimestampTracker() { checkIfClosed(); if (tsTracker == null) { tsTracker = new TimestampTracker(env, getTransactorID()); } return tsTracker; }
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); } }
private Stamp getTimestamp() { return env.getSharedResources().getOracleClient().getStamp(); }
private static Stamp allocateTimestamp(Environment env) { return env.getSharedResources().getTimestampTracker().allocateTimestamp(); }
TransactorCache transactorCache = env.getSharedResources().getTransactorCache(); TxInfoCache txiCache = env.getSharedResources().getTxInfoCache(); env.getSharedResources().getBatchWriter().writeMutations(new ArrayList<>(mutations.values()));
@Override public void close() { if (executor != null) { executor.shutdown(); while (!executor.isTerminated()) { try { executor.awaitTermination(3, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } } } if (exceptionRef.get() != null) { throw new RuntimeException(exceptionRef.get()); } // wait for any async mutations that transactions write to flush env.getSharedResources().getBatchWriter().waitForAsyncFlush(); }
public CommitData createCommitData() { CommitData cd = new CommitData(); cd.cw = env.getSharedResources().getConditionalWriter(); cd.bulkCw = env.getSharedResources().getBulkConditionalWriter(); return cd; }
@Override public MetricRegistry getMetricRegistry() { return env.getSharedResources().getMetricRegistry(); }
/** * Constructs an environment from another environment * * @param env Environment */ @VisibleForTesting public Environment(Environment env) throws Exception { this.table = env.table; this.auths = env.auths; this.accumuloInstance = env.accumuloInstance; this.observers = env.observers; this.weakObservers = env.weakObservers; this.allObserversColumns = env.allObserversColumns; this.conn = env.conn; this.accumuloInstanceID = env.accumuloInstanceID; this.fluoApplicationID = env.fluoApplicationID; this.config = env.config; this.resources = new SharedResources(this); }
@Override public void close() { resources.close(); } }
private static boolean rollbackPrimary(Environment env, long startTs, PrimaryRowColumn prc, byte[] lockValue) { // TODO review use of PrewriteIter here IteratorSetting iterConf = new IteratorSetting(10, PrewriteIterator.class); PrewriteIterator.setSnaptime(iterConf, startTs); ConditionalFlutation delLockMutation = new ConditionalFlutation(env, prc.prow, new FluoCondition(env, prc.pcol).setIterators( iterConf).setValue(lockValue)); // TODO sanity check on lockTs vs startTs delLockMutation.put(prc.pcol, ColumnConstants.DEL_LOCK_PREFIX | startTs, DelLockValue.encode(prc.startTs, true, true)); ConditionalWriter cw = null; cw = env.getSharedResources().getConditionalWriter(); // TODO handle other conditional writer cases try { return cw.write(delLockMutation).getStatus() == Status.ACCEPTED; } catch (AccumuloException e) { throw new RuntimeException(e); } catch (AccumuloSecurityException e) { throw new RuntimeException(e); } }
log.info("The wait command will exit when all notifications are processed"); while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); long ntfyCount = countNotifications(env); long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); if (ntfyCount == 0 && ts1 == (ts2 - 1)) { log.info("All processing has finished!");
/** * Configure properties needed to connect to a Fluo application * * @param conf Job configuration * @param config use {@link FluoConfiguration} to configure programmatically */ @SuppressWarnings("deprecation") public static void configure(Job conf, Configuration config) { try { FluoConfiguration fconfig = new FluoConfiguration(config); try (Environment env = new Environment(fconfig)) { long ts = env.getSharedResources().getTimestampTracker().allocateTimestamp().getTxTimestamp(); conf.getConfiguration().setLong(TIMESTAMP_CONF_KEY, ts); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ConfigurationConverter.getProperties(config).store(baos, ""); conf.getConfiguration().set(PROPS_CONF_KEY, new String(baos.toByteArray(), "UTF8")); AccumuloInputFormat.setZooKeeperInstance(conf, fconfig.getAccumuloInstance(), fconfig.getAccumuloZookeepers()); AccumuloInputFormat.setConnectorInfo(conf, fconfig.getAccumuloUser(), new PasswordToken( fconfig.getAccumuloPassword())); AccumuloInputFormat.setInputTableName(conf, env.getTable()); AccumuloInputFormat.setScanAuthorizations(conf, env.getAuthorizations()); } } catch (Exception e) { throw new RuntimeException(e); } }
public synchronized TransactorNode getTransactorNode() { checkIfClosed(); if (tnode == null) { tnode = new TransactorNode(env, getTransactorID()); } else if (tnode.getStatus() == TrStatus.CLOSED) { throw new IllegalStateException("TransactorNode is closed!"); } return tnode; }
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); } }
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(); }
/** * Constructs an environment from given FluoConfiguration * * @param configuration Configuration used to configure environment */ public Environment(FluoConfiguration configuration) { config = configuration; conn = AccumuloUtil.getConnector(config); readZookeeperConfig(); if (!conn.getInstance().getInstanceName().equals(accumuloInstance)) { throw new IllegalArgumentException("unexpected accumulo instance name " + conn.getInstance().getInstanceName() + " != " + accumuloInstance); } if (!conn.getInstance().getInstanceID().equals(accumuloInstanceID)) { throw new IllegalArgumentException("unexpected accumulo instance id " + conn.getInstance().getInstanceID() + " != " + accumuloInstanceID); } try { resources = new SharedResources(this); } catch (TableNotFoundException e1) { throw new IllegalStateException(e1); } }