CallerContext { public String getContext() { return context; } private  CallerContext(Builder builder); String getContext(); byte[] getSignature(); @InterfaceAudience.Private boolean isContextValid(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static CallerContext getCurrent(); static void setCurrent(CallerContext callerContext); static final Charset SIGNATURE_ENCODING; }
@Test public void testBuilderAppend() { Configuration conf = new Configuration(); conf.set(HADOOP_CALLER_CONTEXT_SEPARATOR_KEY, "$"); CallerContext.Builder builder = new CallerContext.Builder(null, conf); CallerContext context = builder.append("context1") .append("context2").append("key3", "value3").build(); Assert.assertEquals(true, context.getContext().contains("$")); String[] items = context.getContext().split("\\$"); Assert.assertEquals(3, items.length); Assert.assertEquals("key3:value3", items[2]); builder.append("$$"); Assert.assertEquals("context1$context2$key3:value3$$$", builder.build().getContext()); }