static Table writeData(TableName tableName, String... labelExps) throws Exception { Table table = TEST_UTIL.getConnection().getTable(TABLE_NAME); int i = 1; List<Put> puts = new ArrayList<>(labelExps.length); for (String labelExp : labelExps) { Put put = new Put(Bytes.toBytes("row" + i)); put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value); put.setCellVisibility(new CellVisibility(labelExp)); put.setAttribute(NON_VISIBILITY, Bytes.toBytes(TEMP)); puts.add(put); i++; } table.put(puts); return table; } // A simple BaseRegionbserver impl that allows to add a non-visibility tag from the
put.setAttribute("absent", null); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); put.setAttribute("attribute1", Bytes.toBytes("value1")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute1", Bytes.toBytes("value12")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute2", Bytes.toBytes("value2")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2"))); Assert.assertEquals(2, put.getAttributesMap().size()); put.setAttribute("attribute2", null); Assert.assertNull(put.getAttribute("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute2", null); Assert.assertNull(put.getAttribute("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute1", null); Assert.assertNull(put.getAttribute("attribute1")); Assert.assertTrue(put.getAttributesMap().isEmpty());
Put put = new Put(row); put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value); put.setAttribute("visibility", Bytes.toBytes("myTag")); table.put(put); admin.flush(tableName); byte[] value2 = Bytes.toBytes("1000dfsdf"); put2.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value2); put2.setAttribute("visibility", Bytes.toBytes("myTag3")); table.put(put2); admin.flush(tableName);
@Test public void testReplicationWithCellTags() throws Exception { LOG.info("testSimplePutDelete"); Put put = new Put(ROW); put.setAttribute("visibility", Bytes.toBytes("myTag3")); put.addColumn(FAMILY, ROW, ROW); htable1 = utility1.getConnection().getTable(TABLE_NAME); htable1.put(put); Get get = new Get(ROW); try { for (int i = 0; i < NB_RETRIES; i++) { if (i == NB_RETRIES - 1) { fail("Waited too much time for put replication"); } Result res = htable2.get(get); if (res.isEmpty()) { LOG.info("Row not available"); Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(ROW, res.value()); assertEquals(1, TestCoprocessorForTagsAtSink.tags.size()); Tag tag = TestCoprocessorForTagsAtSink.tags.get(0); assertEquals(TAG_TYPE, tag.getType()); break; } } } finally { TestCoprocessorForTagsAtSink.tags = null; } }
@Override protected void populatePut(byte[] lineBytes, ParsedLine parsed, Put put, int i) throws BadTsvLineException, IOException { KeyValue kv; kv = new KeyValue(lineBytes, parsed.getRowKeyOffset(), parsed.getRowKeyLength(), parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0, parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes, parsed.getColumnOffset(i), parsed.getColumnLength(i)); if (parsed.getIndividualAttributes() != null) { String[] attributes = parsed.getIndividualAttributes(); for (String attr : attributes) { String[] split = attr.split(ImportTsv.DEFAULT_ATTRIBUTES_SEPERATOR); if (split == null || split.length <= 1) { throw new BadTsvLineException(msg(attributes)); } else { if (split[0].length() <= 0 || split[1].length() <= 0) { throw new BadTsvLineException(msg(attributes)); } put.setAttribute(split[0], Bytes.toBytes(split[1])); } } } put.add(kv); }
/** * Test that a regionserver is able to abort properly, even when a coprocessor * throws an exception in preStopRegionServer(). */ @Test public void testAbortFromRPC() throws Exception { TableName tableName = TableName.valueOf("testAbortFromRPC"); // create a test table Table table = testUtil.createTable(tableName, FAMILY_BYTES); // write some edits testUtil.loadTable(table, FAMILY_BYTES); LOG.info("Wrote data"); // force a flush cluster.flushcache(tableName); LOG.info("Flushed table"); // Send a poisoned put to trigger the abort Put put = new Put(new byte[]{0, 0, 0, 0}); put.addColumn(FAMILY_BYTES, Bytes.toBytes("c"), new byte[]{}); put.setAttribute(StopBlockingRegionObserver.DO_ABORT, new byte[]{1}); List<HRegion> regions = cluster.findRegionsForTable(tableName); HRegion firstRegion = cluster.findRegionsForTable(tableName).get(0); table.put(put); // Verify that the regionserver is stopped assertNotNull(firstRegion); assertNotNull(firstRegion.getRegionServerServices()); LOG.info("isAborted = " + firstRegion.getRegionServerServices().isAborted()); assertTrue(firstRegion.getRegionServerServices().isAborted()); LOG.info("isStopped = " + firstRegion.getRegionServerServices().isStopped()); assertTrue(firstRegion.getRegionServerServices().isStopped()); }
put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value); int bigTagLen = Short.MAX_VALUE - 5; put.setAttribute("visibility", new byte[bigTagLen]); table.put(put); Put put1 = new Put(row1); value2 = Bytes.toBytes("1000dfsddfdf"); put2.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value2); put.setAttribute("visibility", Bytes.toBytes("ram")); table.put(put2); admin.flush(tableName);
if (!authResult.isAllowed()) { if (cellFeaturesEnabled && !compatibleEarlyTermination) { put.setAttribute(CHECK_COVERING_PERM, TRUE); } else if (authorizationEnabled) { throw new AccessDeniedException("Insufficient permissions " +
if (!authResult.isAllowed()) { if (cellFeaturesEnabled && !compatibleEarlyTermination) { put.setAttribute(CHECK_COVERING_PERM, TRUE); } else if (authorizationEnabled) { throw new AccessDeniedException("Insufficient permissions " + authResult.toContextString());
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
byte[] v = Bytes.toBytes(2L); put.addColumn(f, q, v); put.setAttribute("visibility", Bytes.toBytes("tag1")); table.put(put); Increment increment = new Increment(row1); put = new Put(row3); put.addColumn(f, q, Bytes.toBytes("a")); put.setAttribute("visibility", Bytes.toBytes("tag1")); table.put(put); Append append = new Append(row3);
p.setAttribute("ttl", new byte[] {}); p.addColumn(F, tableName.getName(), Bytes.toBytes(3000L)); t.put(p);
p.setAttribute("versions", new byte[] {}); p.addColumn(F, tableName.getName(), Bytes.toBytes(2)); t.put(p);
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
deleteMarker.setAttribute(entry.getKey(), entry.getValue());
if (put == null) { put = new Put(CellUtil.cloneRow(cell)); put.setAttribute(PhoenixIndexCodec.INDEX_UUID, uuidValue); put.setAttribute(PhoenixIndexCodec.INDEX_PROTO_MD, attribValue); put.setAttribute(BaseScannerRegionObserver.CLIENT_VERSION, clientVersion); put.setAttribute(BaseScannerRegionObserver.REPLAY_WRITES, BaseScannerRegionObserver.REPLAY_ONLY_INDEX_WRITES); mutations.add(put);
if (put == null) { put = new Put(CellUtil.cloneRow(cell)); put.setAttribute(useProto ? PhoenixIndexCodec.INDEX_PROTO_MD : PhoenixIndexCodec.INDEX_MD, indexMetaData); put.setAttribute(PhoenixIndexCodec.INDEX_UUID, uuidValue); put.setAttribute(REPLAY_WRITES, REPLAY_ONLY_INDEX_WRITES); put.setAttribute(BaseScannerRegionObserver.CLIENT_VERSION, clientVersionBytes); mutations.add(put);
put.setAttribute("absent", null); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); put.setAttribute("attribute1", Bytes.toBytes("value1")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttribute("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute1", Bytes.toBytes("value12")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttribute("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute2", Bytes.toBytes("value2")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttribute("attribute2"))); Assert.assertEquals(2, put.getAttributesMap().size()); put.setAttribute("attribute2", null); Assert.assertNull(put.getAttribute("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute2", null); Assert.assertNull(put.getAttribute("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); put.setAttribute("attribute1", null); Assert.assertNull(put.getAttribute("attribute1")); Assert.assertTrue(put.getAttributesMap().isEmpty());
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());