NotificationScanner(Scanner scanner, Predicate<RowColumnValue> filter) { scanner.clearColumns(); Notification.configureScanner(scanner); this.scanner = scanner; this.filter = filter; }
public TestTransaction(Environment env, String trow, Column tcol, long notificationTS) { this(new TransactionImpl(env, new Notification(Bytes.of(trow), tcol, notificationTS)), env); }
@Override public Iterator<RowColumnValue> iterator() { Iterator<RowColumnValue> iter = Iterators.transform(scanner.iterator(), entry -> { Notification n = Notification.from(entry.getKey()); return new RowColumnValue(n.getRow(), n.getColumn(), Bytes.of(entry.getValue().get())); }); return Iterators.filter(iter, rcv -> filter.test(rcv)); } }
public Flutation newDelete(Environment env) { return newDelete(env, getTimestamp()); }
public static String encNonAscii(Notification n) { StringBuilder sb = new StringBuilder(); encNonAscii(sb, n.getRowColumn(), " "); sb.append(" "); sb.append(n.getTimestamp()); return sb.toString(); }
Notification.configureScanner(scanner); if (session.addNotification(finder, Notification.from(entry.getKey()))) { counts.added++;
private void logUnsuccessfulCommit() { log.trace("txid: {} commit() -> UNSUCCESSFUL commitTs: {}", txid, tx.getStats().getCommitTs()); if (!log.isTraceEnabled() && notification != null) { collisionLog.trace("txid: {} trigger: {} {} {}", txid, notification.getRow(), notification.getColumn(), notification.getTimestamp()); } if (!log.isTraceEnabled() && clazz != null) { collisionLog.trace("txid: {} class: {}", txid, clazz.getName()); } collisionLog.trace("txid: {} collisions: {}", txid, toStringEncNonAsciiMBSC(tx.getStats().getRejected())); }
Bytes.of(cu.getColumnVisibility())); if (notification.getColumn().equals(col)) { Key startKey = SpanUtil.toKey(notification.getRowColumn()); startKey.setTimestamp( ColumnConstants.ACK_PREFIX | (Long.MAX_VALUE & ColumnConstants.TIMESTAMP_MASK)); Key endKey = SpanUtil.toKey(notification.getRowColumn()); endKey.setTimestamp(ColumnConstants.ACK_PREFIX | (notification.getTimestamp() + 1)); .writeMutationAsync(notification.newDelete(env)); return true;
@VisibleForTesting static boolean shouldProcess(Notification notification, int divisor, int remainder) { byte[] cfcq = NotificationUtil.encodeCol(notification.getColumn()); return NotificationHashFilter.accept(ByteUtil.toByteSequence(notification.getRow()), new ArrayByteSequence(cfcq), divisor, remainder); }
public static long getNotificationTS(Environment env, String row, Column col) { Scanner scanner; try { scanner = env.getAccumuloClient().createScanner(env.getTable(), env.getAuthorizations()); } catch (TableNotFoundException e) { throw new RuntimeException(e); } IteratorSetting iterCfg = new IteratorSetting(11, NotificationIterator.class); scanner.addScanIterator(iterCfg); Text cv = ByteUtil.toText(col.getVisibility()); scanner.setRange(SpanUtil.toRange(Span.prefix(row))); scanner.fetchColumn(ByteUtil.toText(ColumnConstants.NOTIFY_CF), new Text(NotificationUtil.encodeCol(col))); for (Entry<Key, org.apache.accumulo.core.data.Value> entry : scanner) { if (entry.getKey().getColumnVisibility().equals(cv)) { return Notification.from(entry.getKey()).getTimestamp(); } } throw new RuntimeException("No notification found"); }
private ConditionalFlutation prewrite(ConditionalFlutation cm, Bytes row, Column col, Bytes val, Bytes primaryRow, Column primaryColumn, boolean isTriggerRow) { IteratorSetting iterConf = new IteratorSetting(10, PrewriteIterator.class); PrewriteIterator.setSnaptime(iterConf, startTs); boolean isTrigger = isTriggerRow && col.equals(notification.getColumn()); if (isTrigger) { PrewriteIterator.enableAckCheck(iterConf, notification.getTimestamp()); } if (isReadLock(val)) { PrewriteIterator.setReadlock(iterConf); } Condition cond = new FluoCondition(env, col).setIterators(iterConf); if (cm == null) { cm = new ConditionalFlutation(env, row, cond); } else { cm.addCondition(cond); } if (isWrite(val) && !isDelete(val)) { cm.put(col, ColumnConstants.DATA_PREFIX | startTs, val.toArray()); } if (isReadLock(val)) { cm.put(col, ColumnConstants.RLOCK_PREFIX | ReadLockUtil.encodeTs(startTs, false), ReadLockValue.encode(primaryRow, primaryColumn, getTransactorID())); } else { cm.put(col, ColumnConstants.LOCK_PREFIX | startTs, LockValue.encode(primaryRow, primaryColumn, isWrite(val), isDelete(val), isTriggerRow, getTransactorID())); } return cm; }
primRow = primary.getRow(); primCol = primary.getColumn(); if (notification != null && !primary.equals(notification.getRowColumn())) { throw new IllegalArgumentException("Primary must be notification"); primRow = notification.getRow(); primCol = notification.getColumn(); } else {
@Override public int compareTo(FutureNotificationTask o) { return Long.compare(notification.getTimestamp(), o.notification.getTimestamp()); }
private boolean isTriggerRow(Bytes row) { return notification != null && notification.getRow().equals(row); }
@Override public Collection<Mutation> createMutations(CommitData cd) { long commitTs = getStats().getCommitTs(); ArrayList<Mutation> mutations = new ArrayList<>(updates.size() + 1); for (Entry<Bytes, Map<Column, Bytes>> rowUpdates : updates.entrySet()) { Flutation m = new Flutation(env, rowUpdates.getKey()); boolean isTriggerRow = isTriggerRow(rowUpdates.getKey()); for (Entry<Column, Bytes> colUpdates : rowUpdates.getValue().entrySet()) { ColumnUtil.commitColumn(env, isTriggerRow && colUpdates.getKey().equals(notification.getColumn()), false, colUpdates.getKey(), isWrite(colUpdates.getValue()), isDelete(colUpdates.getValue()), isReadLock(colUpdates.getValue()), startTs, commitTs, observedColumns, m); } mutations.add(m); } return mutations; }
Notification.configureScanner(scanner); if (session.addNotification(finder, Notification.from(entry.getKey()))) { counts.added++;
private void logUnsuccessfulCommit() { log.trace("txid: {} commit() -> UNSUCCESSFUL commitTs: {}", txid, tx.getStats().getCommitTs()); if (!log.isTraceEnabled() && notification != null) { collisionLog.trace("txid: {} trigger: {} {} {}", txid, notification.getRow(), notification.getColumn(), notification.getTimestamp()); } if (!log.isTraceEnabled() && clazz != null) { collisionLog.trace("txid: {} class: {}", txid, clazz.getName()); } collisionLog.trace("txid: {} collisions: {}", txid, toStringEncNonAsciiMBSC(tx.getStats().getRejected())); }
Bytes.of(cu.getColumnVisibility())); if (notification.getColumn().equals(col)) { Key startKey = SpanUtil.toKey(notification.getRowColumn()); startKey.setTimestamp(ColumnType.ACK.first()); Key endKey = SpanUtil.toKey(notification.getRowColumn()); endKey.setTimestamp(ColumnType.ACK.encode(notification.getTimestamp() + 1)); .writeMutationAsync(notification.newDelete(env)); return true;
public TransactionImpl(Environment env, Notification trigger, long startTs) { Objects.requireNonNull(env, "environment cannot be null"); Preconditions.checkArgument(startTs >= 0, "startTs cannot be negative"); this.env = env; this.stats = new TxStats(env); this.startTs = startTs; this.observedColumns = env.getConfiguredObservers().getObservedColumns(STRONG); if (trigger != null && env.getConfiguredObservers().getObservedColumns(WEAK).contains(trigger.getColumn())) { this.weakNotification = trigger; } else { this.notification = trigger; } if (notification != null) { Map<Column, Bytes> colUpdates = new HashMap<>(); colUpdates.put(notification.getColumn(), NTFY_VAL); updates.put(notification.getRow(), colUpdates); } }
public static String encNonAscii(Notification n) { StringBuilder sb = new StringBuilder(); encNonAscii(sb, n.getRowColumn(), " "); sb.append(" "); sb.append(n.getTimestamp()); return sb.toString(); }