public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
public TephraTransactionContext(byte[] txnBytes) throws IOException { this(); this.tx = CODEC.decode(txnBytes); }
@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; } } }
@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; } } }
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; }
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; }
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; }
@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; } } }
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; }
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; }
/** * Creates a {@link CloseableIterator} of {@link RawMessage} based on the given fetch request. */ private CloseableIterator<RawMessage> fetchMessages(GenericRecord fetchRequest, TopicId topicId) throws IOException, TopicNotFoundException { MessageFetcher fetcher = messagingService.prepareFetch(topicId); Object startFrom = fetchRequest.get("startFrom"); if (startFrom != null) { if (startFrom instanceof ByteBuffer) { // start message id is specified fetcher.setStartMessage(Bytes.toBytes((ByteBuffer) startFrom), (Boolean) fetchRequest.get("inclusive")); } else if (startFrom instanceof Long) { // start by timestamp is specified fetcher.setStartTime((Long) startFrom); } else { // This shouldn't happen as it's guaranteed by the schema LOG.warn("Ignore unrecognized type for startFrom. Type={}, Value={}", startFrom.getClass(), startFrom); } } Integer limit = (Integer) fetchRequest.get("limit"); if (limit != null) { fetcher.setLimit(limit); } ByteBuffer encodedTx = (ByteBuffer) fetchRequest.get("transaction"); if (encodedTx != null) { fetcher.setTransaction(TRANSACTION_CODEC.decode(ByteBuffers.getByteArray(encodedTx))); } return fetcher.fetch(); }
/** * Creates a {@link CloseableIterator} of {@link RawMessage} based on the given fetch request. */ private CloseableIterator<RawMessage> fetchMessages(GenericRecord fetchRequest, TopicId topicId) throws IOException, TopicNotFoundException { MessageFetcher fetcher = messagingService.prepareFetch(topicId); Object startFrom = fetchRequest.get("startFrom"); if (startFrom != null) { if (startFrom instanceof ByteBuffer) { // start message id is specified fetcher.setStartMessage(Bytes.toBytes((ByteBuffer) startFrom), (Boolean) fetchRequest.get("inclusive")); } else if (startFrom instanceof Long) { // start by timestamp is specified fetcher.setStartTime((Long) startFrom); } else { // This shouldn't happen as it's guaranteed by the schema LOG.warn("Ignore unrecognized type for startFrom. Type={}, Value={}", startFrom.getClass(), startFrom); } } Integer limit = (Integer) fetchRequest.get("limit"); if (limit != null) { fetcher.setLimit(limit); } ByteBuffer encodedTx = (ByteBuffer) fetchRequest.get("transaction"); if (encodedTx != null) { fetcher.setTransaction(TRANSACTION_CODEC.decode(ByteBuffers.getByteArray(encodedTx))); } return fetcher.fetch(); }
if (fs.exists(txFile)) { try (FSDataInputStream txFileInputStream = fs.open(txFile)) { transaction = new TransactionCodec().decode(ByteStreams.toByteArray(txFileInputStream));
if (fs.exists(txFile)) { try (FSDataInputStream txFileInputStream = fs.open(txFile)) { transaction = new TransactionCodec().decode(ByteStreams.toByteArray(txFileInputStream));