/** * Convert a stringified protocol buffer exception Parameter to a Java Exception * * @param parameter the protocol buffer Parameter to convert * @return the converted Exception * @throws IOException if failed to deserialize the parameter */ @SuppressWarnings("unchecked") public static Throwable toException(final NameBytesPair parameter) throws IOException { if (parameter == null || !parameter.hasValue()) return null; String desc = parameter.getValue().toStringUtf8(); String type = parameter.getName(); try { Class<? extends Throwable> c = (Class<? extends Throwable>)Class.forName(type, true, ClassLoaderHolder.CLASS_LOADER); Constructor<? extends Throwable> cn = null; try { cn = c.getDeclaredConstructor(String.class); return cn.newInstance(desc); } catch (NoSuchMethodException e) { // Could be a raw RemoteException. See HBASE-8987. cn = c.getDeclaredConstructor(String.class, String.class); return cn.newInstance(type, desc); } } catch (Exception e) { throw new IOException(e); } }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (hasName()) { hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); } if (hasValue()) { hash = (37 * hash) + VALUE_FIELD_NUMBER; hash = (53 * hash) + getValue().hashCode(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; }
@Override public VisibilityLabelsResponse run() throws Exception { String[] labels = { "L1", SECRET, "L2", "invalid~", "L3" }; VisibilityLabelsResponse response = null; try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.addLabels(conn, labels); } catch (Throwable e) { throw new IOException(e); } List<RegionActionResult> resultList = response.getResultList(); assertEquals(5, resultList.size()); assertTrue(resultList.get(0).getException().getValue().isEmpty()); assertEquals("org.apache.hadoop.hbase.DoNotRetryIOException", resultList.get(1) .getException().getName()); assertTrue(Bytes.toString(resultList.get(1).getException().getValue().toByteArray()) .contains( "org.apache.hadoop.hbase.security.visibility.LabelAlreadyExistsException: " + "Label 'secret' already exists")); assertTrue(resultList.get(2).getException().getValue().isEmpty()); assertTrue(resultList.get(3).getException().getValue().isEmpty()); assertTrue(resultList.get(4).getException().getValue().isEmpty()); return null; } };
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
delete.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
mutation.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
/** * Convert a stringified protocol buffer exception Parameter to a Java Exception * * @param parameter the protocol buffer Parameter to convert * @return the converted Exception * @throws IOException if failed to deserialize the parameter */ @SuppressWarnings("unchecked") public static Throwable toException(final NameBytesPair parameter) throws IOException { if (parameter == null || !parameter.hasValue()) return null; String desc = parameter.getValue().toStringUtf8(); String type = parameter.getName(); try { Class<? extends Throwable> c = (Class<? extends Throwable>)Class.forName(type, true, ClassLoaderHolder.CLASS_LOADER); Constructor<? extends Throwable> cn = null; try { cn = c.getDeclaredConstructor(String.class); return cn.newInstance(desc); } catch (NoSuchMethodException e) { // Could be a raw RemoteException. See HBASE-8987. cn = c.getDeclaredConstructor(String.class, String.class); return cn.newInstance(type, desc); } } catch (Exception e) { throw new IOException(e); } }
put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
scan.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
VisibilityLabelsResponse response = NORMAL_USER1.runAs(action); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(0).getException().getName()); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(1).getException().getName()); response = NORMAL_USER1.runAs(action); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(0).getException().getName()); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(1).getException().getName()); response = NORMAL_USER1.runAs(action); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response.getResult(0) .getException().getName()); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response.getResult(1) .getException().getName());
delete.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
response = NORMAL_USER1.runAs(action); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(0).getException().getName()); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(1).getException().getName()); response = NORMAL_USER1.runAs(action2); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(0).getException().getName()); assertEquals("org.apache.hadoop.hbase.security.AccessDeniedException", response .getResult(1).getException().getName()); response = SUPERUSER.runAs(action2); assertTrue(response.getResult(0).getException().getValue().isEmpty());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
assertTrue(resultList.get(0).getException().getValue().isEmpty()); assertEquals("org.apache.hadoop.hbase.DoNotRetryIOException", resultList.get(1).getException().getName()); assertTrue(Bytes.toString(resultList.get(1).getException().getValue().toByteArray()) .contains(
mutation.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair)) { return super.equals(obj); } org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair other = (org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair) obj; boolean result = true; result = result && (hasName() == other.hasName()); if (hasName()) { result = result && getName() .equals(other.getName()); } result = result && (hasValue() == other.hasValue()); if (hasValue()) { result = result && getValue() .equals(other.getValue()); } result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
/** * <code>required string name = 1;</code> */ public Builder clearName() { bitField0_ = (bitField0_ & ~0x00000001); name_ = getDefaultInstance().getName(); onChanged(); return this; } /**