@Override public byte[] encodeTransaction() throws SQLException { Transaction tx = getCurrentTransaction(); assert (tx != null); try { byte[] encodedTxBytes = CODEC.encode(tx); encodedTxBytes = Arrays.copyOf(encodedTxBytes, encodedTxBytes.length + 1); encodedTxBytes[encodedTxBytes.length - 1] = getProvider().getCode(); return encodedTxBytes; } catch (IOException e) { throw new SQLException(e); } }
public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
public HBaseTable(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> args, CConfiguration cConf, Configuration hConf, HBaseTableUtil tableUtil) throws IOException { this(datasetContext, spec, args, cConf, hConf, tableUtil, new TransactionCodec()); }
scan.setCacheBlocks(false); scan.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, new TransactionCodec().encode(tx)); job.setNumReduceTasks(0);
if (fs.exists(txFile)) { try (FSDataInputStream txFileInputStream = fs.open(txFile)) { transaction = new TransactionCodec().decode(ByteStreams.toByteArray(txFileInputStream));
FileSystem fs = txFile.getFileSystem(configuration); try (FSDataOutputStream fsDataOutputStream = fs.create(txFile, false)) { fsDataOutputStream.write(new TransactionCodec().encode(transaction));
if (fs.exists(txFile)) { try (FSDataInputStream txFileInputStream = fs.open(txFile)) { transaction = new TransactionCodec().decode(ByteStreams.toByteArray(txFileInputStream));
private byte[] getEncodedTx() throws IOException { if (encodedTx == null) { encodedTx = txCodec.encode(tx); } return encodedTx; }
public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
FileSystem fs = txFile.getFileSystem(configuration); try (FSDataOutputStream fsDataOutputStream = fs.create(txFile, false)) { fsDataOutputStream.write(new TransactionCodec().encode(transaction));
public HBaseTable(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> args, CConfiguration cConf, Configuration hConf, HBaseTableUtil tableUtil) throws IOException { this(datasetContext, spec, args, cConf, hConf, tableUtil, new TransactionCodec()); }
private byte[] getEncodedTx() throws IOException { if (encodedTx == null) { encodedTx = txCodec.encode(tx); } return encodedTx; }
public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
public TransactionProcessor() { this.txCodec = new TransactionCodec(); }
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException { op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx)); }
@Nullable private Transaction getTransaction(int stageId) throws TransactionFailureException { try { URL url = txServiceBaseURI.resolve("/spark/stages/" + stageId + "/transaction").toURL(); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); try { int responseCode = urlConn.getResponseCode(); if (responseCode == 200) { return TX_CODEC.decode(ByteStreams.toByteArray(urlConn.getInputStream())); } if (responseCode == 404) { return null; } throw new TransactionFailureException( String.format("No transaction for stage %d. Reason: %s", stageId, Bytes.toString(ByteStreams.toByteArray(urlConn.getErrorStream())))); } finally { urlConn.disconnect(); } } catch (IOException e) { // If not able to talk to the tx service, just treat it the same as 404 so that there could be retry. return null; } } }
public TransactionProcessor() { this.txCodec = new TransactionCodec(); }
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException { op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx)); }
private Transaction getFromOperation(OperationWithAttributes op) throws IOException { byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY); if (encoded == null) { // to support old clients encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY); } if (encoded != null) { return txCodec.decode(encoded); } return null; }
public TransactionProcessor() { this.txCodec = new TransactionCodec(); }