public ColumnFamily updateForKey( ByteBuffer key, ColumnNameBuilder builder, UpdateParameters params) throws InvalidRequestException { CFDefinition cfDef = cfm.getCfDef(); ColumnFamily cf = UnsortedColumns.factory.create(cfm); // Inserting the CQL row marker (see #4361) // We always need to insert a marker, because of the following situation: // CREATE TABLE t ( k int PRIMARY KEY, c text ); // INSERT INTO t(k, c) VALUES (1, 1) // DELETE c FROM t WHERE k = 1; // SELECT * FROM t; // The last query should return one row (but with c == null). Adding // the marker with the insert make sure the semantic is correct (while making sure a // 'DELETE FROM t WHERE k = 1' does remove the row entirely) // // We never insert markers for Super CF as this would confuse the thrift side. if (cfDef.isComposite && !cfDef.isCompact && !cfm.isSuper()) { ByteBuffer name = builder.copy().add(ByteBufferUtil.EMPTY_BYTE_BUFFER).build(); cf.addColumn(params.makeColumn(name, ByteBufferUtil.EMPTY_BYTE_BUFFER)); } List<Operation> updates = getOperations(); if (cfDef.isCompact) { if (builder.componentCount() == 0) throw new InvalidRequestException( String.format("Missing PRIMARY KEY part %s", cfDef.columns.values().iterator().next())); if (cfDef.value == null) { // compact + no compact value implies there is no column outside the PK. So no operation // could // have passed through validation assert updates.isEmpty(); setToEmptyOperation.execute(key, cf, builder.copy(), params); } else { // compact means we don't have a row marker, so don't accept to set only the PK. See // CASSANDRA-5648. if (updates.isEmpty()) throw new InvalidRequestException( String.format("Column %s is mandatory for this COMPACT STORAGE table", cfDef.value)); for (Operation update : updates) update.execute(key, cf, builder.copy(), params); } } else { for (Operation update : updates) update.execute(key, cf, builder.copy(), params); } return cf; }
private void runtTest(Operation o) throws NotSupportedException, SystemException, RollbackException, HeuristicMixedException, HeuristicRollbackException { log.trace("Here is where the fun starts.."); tm(0).begin(); o.execute(); assertKeyLockedCorrectly(k0); assertEquals(crm.lockCount, 0); assertEquals(crm.clusterGet, 1); assertEquals(crm.otherCount, 0); tm(0).commit(); eventually( new Condition() { @Override public boolean isSatisfied() throws Exception { return crm.lockCount == 0 && crm.clusterGet == 1 && crm.otherCount == 1; // 1-phase commit } }); }
private <T> T executeInternal(Operation<T> operation) { try { internalCall.set(true); return operation.execute(); } finally { internalCall.set(false); } }
/** * Execute the next instruction in the program, and ready the programCounter, etc. to run the next * instruction after that * * @throws StackRuntimeException */ public void step() throws StackRuntimeException { if (isRunning()) { Instruction nextInstruction = instructions.get(programCounter); Operation op = Operations.get(nextInstruction.name); if (op != null) setProgramCounter(op.execute(this, nextInstruction.arg)); else throw new RuntimeException("Invalid instruction passed to StackMachine"); numInstructions++; } }
synchronized <T> T doOperation(Operation<T> operation) throws IOException { isTrue("open", !closed); usageCount++; try { return operation.execute(); } catch (IOException ioe) { close(); throw ioe; } finally { lastUsedAt = System.currentTimeMillis(); _activeState = null; } }
public void run() { Operation op = null; while ((op = iTasks.next()) != null) { long t0 = System.currentTimeMillis(); try { double val = op.execute(getServer()); iQuality.inc(val); } catch (Throwable t) { sLog.warn("Task failed: " + t.getMessage(), t); } finally { iFinished.inc(1); } long t1 = System.currentTimeMillis(); iRunTime = (t1 - iT0) / 1000.0; iExec.inc(t1 - t0); } }
/** * Run the current <code>Operation</code> * * @return true if it could be executed completely, false if it was cancelled during the run. */ private boolean runJob() { Throwable throwable = null; Outcome outcome = null; try { outcome = job.execute(); } catch (Throwable t) { throwable = t; outcome = Outcome.EXCEPTION; } setStartDate(null); // If we were cancelled during the run, end. The manager should have been // notified at the time of cancellation if (getStatus() != Status.RUNNING) { return false; } else { setStatus(Status.IDLE); jobDone(outcome, throwable); return true; } }
public void process(Exchange exchange) { Operation operation = getOperation(exchange); operation.setBasicCache(cache); operation.setConfiguration(configuration); operation.execute(exchange); }