public void close(Reporter reporter) throws IOException { m_table.close(); }
@Override protected void cleanup(org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException { for (int i = 0; i < DEFAULT_TABLES_COUNT; i++) { if (tables[i] != null) { tables[i].close(); } } }
@Override public void close(TaskAttemptContext context) throws IOException { for (BufferedMutator mutator : mutatorMap.values()) { mutator.close(); } if (connection != null) { connection.close(); } }
public void close(Reporter reporter) throws IOException { try { if (this.m_mutator != null) { this.m_mutator.close(); } } finally { if (conn != null) { this.conn.close(); } } }
@Override protected void finalize() throws Throwable { try { m_table.close(); m_connection.close(); } finally { super.finalize(); } }
@Override public void close() throws IOException { table.flush(); table.close(); } }
@Override void onTakedown() throws IOException { mutator.close(); table.close(); } }
@Override void testTakedown() throws IOException { if (flushCommits) { this.mutator.flush(); } mutator.close(); } }
@Override public void cleanup(Context context) throws IOException { mutator.close(); connection.close(); }
@Override protected void cleanup(Context context) throws IOException ,InterruptedException { joinWalkers(); mutator.close(); connection.close(); }
@Override public void stop() { try { if (table != null) { table.close(); } table = null; } catch (IOException e) { throw new FlumeException("Error closing table.", e); } try { if (conn != null) { conn.close(); } conn = null; } catch (IOException e) { throw new FlumeException("Error closing connection.", e); } sinkCounter.incrementConnectionClosedCount(); sinkCounter.stop(); }
public static void generateHBaseDatasetNullStr(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor("f")); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); Put p = new Put("a1".getBytes()); p.addColumn("f".getBytes(), "c1".getBytes(), "".getBytes()); p.addColumn("f".getBytes(), "c2".getBytes(), "".getBytes()); p.addColumn("f".getBytes(), "c3".getBytes(), "5".getBytes()); p.addColumn("f".getBytes(), "c4".getBytes(), "".getBytes()); table.mutate(p); table.close(); }
@Test public void testBufferedMutatorImplWithSharedPool() throws Exception { ClusterConnection conn = createHConnection(); MyAsyncProcess ap = new MyAsyncProcess(conn, CONF); BufferedMutatorParams bufferParam = createBufferedMutatorParams(ap, DUMMY_TABLE); BufferedMutator ht = new BufferedMutatorImpl(conn, bufferParam, ap); ht.close(); assertFalse(ap.service.isShutdown()); }
public static void generateHBaseDatasetDoubleOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); for (double i = 0.5; i <= 100.00; i += 0.75) { byte[] bytes = new byte[9]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9); OrderedBytes.encodeFloat64(br, i, Order.ASCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
public static void generateHBaseDatasetIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); for (int i = -49; i <= 100; i++) { byte[] bytes = new byte[5]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5); OrderedBytes.encodeInt32(br, i, Order.DESCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
public static void generateHBaseDatasetIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); for (int i = -49; i <= 100; i++) { byte[] bytes = new byte[5]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5); OrderedBytes.encodeInt32(br, i, Order.ASCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
public static void generateHBaseDatasetDoubleOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); for (double i = 0.5; i <= 100.00; i += 0.75) { byte[] bytes = new byte[9]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9); OrderedBytes.encodeFloat64(br, i, Order.DESCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
public static void generateHBaseDatasetFloatOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); for (float i = (float)0.5; i <= 100.00; i += 0.75) { byte[] bytes = new byte[5]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5); OrderedBytes.encodeFloat32(br, i, Order.DESCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
public static void generateHBaseDatasetBigIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception { if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(FAMILY_F)); if (numberRegions > 1) { admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1)); } else { admin.createTable(desc); } BufferedMutator table = conn.getBufferedMutator(tableName); long startTime = (long)1438034423 * 1000; for (long i = startTime; i <= startTime + 100; i++) { byte[] bytes = new byte[9]; PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9); OrderedBytes.encodeInt64(br, i, Order.ASCENDING); Put p = new Put(bytes); p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes()); table.mutate(p); } table.close(); admin.flush(tableName); }
@Test public void testMultiMetrics() throws Exception { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); conf.set(MetricsConnection.CLIENT_SIDE_METRICS_ENABLED_KEY, "true"); ConnectionImplementation conn = (ConnectionImplementation) ConnectionFactory.createConnection(conf); try { BufferedMutator mutator = conn.getBufferedMutator(TABLE_NAME); byte[][] keys = {Bytes.toBytes("aaa"), Bytes.toBytes("mmm"), Bytes.toBytes("zzz")}; for (byte[] key : keys) { Put p = new Put(key); p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(10)); mutator.mutate(p); } mutator.flush(); mutator.close(); MetricsConnection metrics = conn.getConnectionMetrics(); assertEquals(1, metrics.multiTracker.reqHist.getCount()); assertEquals(3, metrics.numActionsPerServerHist.getSnapshot().getMean(), 1e-15); assertEquals(1, metrics.numActionsPerServerHist.getCount()); } finally { conn.close(); } } }