public boolean finishCommit(CommitData cd, Stamp commitStamp) throws TableNotFoundException, MutationsRejectedException { long commitTs = commitStamp.getTxTimestamp(); // delete locks and add writes for other columns 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(), colUpdates.getValue() != null, colUpdates.getValue() == DELETE, startTs, commitTs, observedColumns, m); } mutations.add(m); } ArrayList<Mutation> afterFlushMutations = new ArrayList<>(2); Flutation m = new Flutation(env, cd.prow); // mark transaction as complete for garbage collection purposes m.put(cd.pcol, ColumnConstants.TX_DONE_PREFIX | commitTs, EMPTY); afterFlushMutations.add(m); if (weakNotification != null) { afterFlushMutations.add(weakNotification.newDelete(env, startTs)); } if (notification != null) { afterFlushMutations.add(notification.newDelete(env, startTs)); } env.getSharedResources().getBatchWriter().writeMutationsAsync(mutations, afterFlushMutations); return true; }
private static Map<Column, ObserverConfiguration> readObservers(DataInputStream dis) throws IOException { HashMap<Column, ObserverConfiguration> omap = new HashMap<>(); int num = WritableUtils.readVInt(dis); for (int i = 0; i < num; i++) { Column col = ColumnUtil.readColumn(dis); String clazz = dis.readUTF(); Map<String, String> params = new HashMap<>(); int numParams = WritableUtils.readVInt(dis); for (int j = 0; j < numParams; j++) { String k = dis.readUTF(); String v = dis.readUTF(); params.put(k, v); } ObserverConfiguration observerConfig = new ObserverConfiguration(clazz); observerConfig.setParameters(params); omap.put(col, observerConfig); } return omap; }
private static void serializeObservers(DataOutputStream dos, Map<Column, ObserverConfiguration> colObservers) throws IOException { // TODO use a human readable serialized format like json Set<Entry<Column, ObserverConfiguration>> es = colObservers.entrySet(); WritableUtils.writeVInt(dos, colObservers.size()); for (Entry<Column, ObserverConfiguration> entry : es) { ColumnUtil.writeColumn(entry.getKey(), dos); dos.writeUTF(entry.getValue().getClassName()); Map<String, String> params = entry.getValue().getParameters(); WritableUtils.writeVInt(dos, params.size()); for (Entry<String, String> pentry : entry.getValue().getParameters().entrySet()) { dos.writeUTF(pentry.getKey()); dos.writeUTF(pentry.getValue()); } } }
RollbackCheckIterator.setLocktime(is, startTs); Entry<Key, Value> entry = ColumnUtil.checkColumn(env, is, prow, pcol);
private static void commitColumns(Environment env, PrimaryRowColumn prc, List<Entry<Key, Value>> value, long commitTs, Map<ByteSequence, Mutation> mutations) { for (Entry<Key, Value> entry : value) { if (isPrimary(prc, entry.getKey())) { continue; } long lockTs = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; // TODO may be that a stronger sanity check that could be done here if (commitTs < lockTs) { throw new IllegalStateException("bad commitTs : " + entry.getKey() + " (" + commitTs + "<" + lockTs + ")"); } Mutation mut = getMutation(entry.getKey().getRowData(), mutations); Column col = SpanUtil.toRowColumn(entry.getKey()).getColumn(); LockValue lv = new LockValue(entry.getValue().get()); ColumnUtil.commitColumn(env, lv.isTrigger(), false, col, lv.isWrite(), lv.isDelete(), lockTs, commitTs, env.getObservers().keySet(), mut); } }
ConditionalMutation delLockMutation = new ConditionalFlutation(env, cd.prow, lockCheck); ColumnUtil.commitColumn(env, isTrigger, true, cd.pcol, cd.pval != null, cd.pval == DELETE, startTs, commitTs, observedColumns, delLockMutation);