Java Code Examples for org.apache.hadoop.hbase.client.Durability#SKIP_WAL
The following examples show how to use
org.apache.hadoop.hbase.client.Durability#SKIP_WAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseBolt.java From metron with Apache License 2.0 | 6 votes |
/** * Saves an operation for later. * @param tuple Contains the data elements that need written to HBase. */ private void save(Tuple tuple) { byte[] rowKey = mapper.rowKey(tuple); ColumnList cols = mapper.columns(tuple); Durability durability = writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL; Optional<Long> ttl = mapper.getTTL(tuple); if(ttl.isPresent()) { hbaseClient.addMutation(rowKey, cols, durability, ttl.get()); } else { hbaseClient.addMutation(rowKey, cols, durability); } batchHelper.addBatch(tuple); LOG.debug("Added mutation to the batch; size={}", batchHelper.getBatchSize()); }
Example 2
Source File: ProtobufUtil.java From hbase with Apache License 2.0 | 6 votes |
/** * Convert a protobuf Durability into a client Durability */ public static Durability toDurability( final ClientProtos.MutationProto.Durability proto) { switch(proto) { case USE_DEFAULT: return Durability.USE_DEFAULT; case SKIP_WAL: return Durability.SKIP_WAL; case ASYNC_WAL: return Durability.ASYNC_WAL; case SYNC_WAL: return Durability.SYNC_WAL; case FSYNC_WAL: return Durability.FSYNC_WAL; default: return Durability.USE_DEFAULT; } }
Example 3
Source File: Indexer.java From phoenix with Apache License 2.0 | 5 votes |
/** * Add the index updates to the WAL, or write to the index table, if the WAL has been disabled * @return <tt>true</tt> if the WAL has been updated. * @throws IOException */ private boolean doPre(Collection<Pair<Mutation, byte[]>> indexUpdates, final WALEdit edit, final Durability durability) throws IOException { // no index updates, so we are done if (indexUpdates == null || indexUpdates.size() == 0) { return false; } // if writing to wal is disabled, we never see the WALEdit updates down the way, so do the index // update right away if (durability == Durability.SKIP_WAL) { try { this.writer.write(indexUpdates); return false; } catch (Throwable e) { LOG.error("Failed to update index with entries:" + indexUpdates, e); IndexManagementUtil.rethrowIndexingException(e); } } // we have all the WAL durability, so we just update the WAL entry and move on for (Pair<Mutation, byte[]> entry : indexUpdates) { edit.add(new IndexedKeyValue(entry.getSecond(), entry.getFirst())); } return true; }
Example 4
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 5 votes |
private static Durability durabilityFromThrift(TDurability tDurability) { switch (tDurability.getValue()) { case 0: return Durability.USE_DEFAULT; case 1: return Durability.SKIP_WAL; case 2: return Durability.ASYNC_WAL; case 3: return Durability.SYNC_WAL; case 4: return Durability.FSYNC_WAL; default: return Durability.USE_DEFAULT; } }
Example 5
Source File: WALSplitUtil.java From hbase with Apache License 2.0 | 5 votes |
public MutationReplay(ClientProtos.MutationProto.MutationType type, Mutation mutation, long nonceGroup, long nonce) { this.type = type; this.mutation = mutation; if (this.mutation.getDurability() != Durability.SKIP_WAL) { // using ASYNC_WAL for relay this.mutation.setDurability(Durability.ASYNC_WAL); } this.nonceGroup = nonceGroup; this.nonce = nonce; }
Example 6
Source File: MutationTest.java From phoenix with Apache License 2.0 | 5 votes |
private void testDurability(boolean disableWAL) throws Exception { try(Connection conn = DriverManager.getConnection(getUrl())) { Durability expectedDurability = disableWAL ? Durability.SKIP_WAL : Durability.USE_DEFAULT; conn.setAutoCommit(false); conn.createStatement().execute("CREATE TABLE t1 (k integer not null primary key, a.k varchar, b.k varchar) " + (disableWAL ? "DISABLE_WAL=true" : "")); conn.createStatement().execute("UPSERT INTO t1 VALUES(1,'a','b')"); conn.createStatement().execute("DELETE FROM t1 WHERE k=2"); assertDurability(conn,expectedDurability); conn.createStatement().execute("DELETE FROM t1 WHERE k=1"); assertDurability(conn,expectedDurability); conn.rollback(); conn.createStatement().execute("DROP TABLE t1"); } }
Example 7
Source File: Indexer.java From phoenix with Apache License 2.0 | 4 votes |
private void doPostWithExceptions(WALEdit edit, Mutation m, final Durability durability) throws Exception { //short circuit, if we don't need to do any work if (durability == Durability.SKIP_WAL || !this.builder.isEnabled(m)) { // already did the index update in prePut, so we are done return; } // get the current span, or just use a null-span to avoid a bunch of if statements try (TraceScope scope = Trace.startSpan("Completing index writes")) { Span current = scope.getSpan(); if (current == null) { current = NullSpan.INSTANCE; } // there is a little bit of excess here- we iterate all the non-indexed kvs for this check first // and then do it again later when getting out the index updates. This should be pretty minor // though, compared to the rest of the runtime IndexedKeyValue ikv = getFirstIndexedKeyValue(edit); /* * early exit - we have nothing to write, so we don't need to do anything else. NOTE: we don't * release the WAL Rolling lock (INDEX_UPDATE_LOCK) since we never take it in doPre if there are * no index updates. */ if (ikv == null) { return; } /* * only write the update if we haven't already seen this batch. We only want to write the batch * once (this hook gets called with the same WALEdit for each Put/Delete in a batch, which can * lead to writing all the index updates for each Put/Delete). */ if (!ikv.getBatchFinished()) { Collection<Pair<Mutation, byte[]>> indexUpdates = extractIndexUpdate(edit); // the WAL edit is kept in memory and we already specified the factory when we created the // references originally - therefore, we just pass in a null factory here and use the ones // already specified on each reference try { current.addTimelineAnnotation("Actually doing index update for first time"); writer.writeAndKillYourselfOnFailure(indexUpdates); } finally { // With a custom kill policy, we may throw instead of kill the server. // Without doing this in a finally block (at least with the mini cluster), // the region server never goes down. // mark the batch as having been written. In the single-update case, this never gets check // again, but in the batch case, we will check it again (see above). ikv.markBatchFinished(); } } } }