@InterfaceAudience.Private
 @Override
 protected void flush() throws IOException {
   for (MetricsContext ctxt : subctxt) {
     try {
       ((AbstractMetricsContext) ctxt).flush();
     } catch (IOException e) {
       LOG.warn("flush failed: " + ctxt.getContextName(), e);
     }
   }
 }
 @InterfaceAudience.Private
 @Override
 protected void emitRecord(String contextName, String recordName, OutputRecord outRec)
     throws IOException {
   for (MetricsContext ctxt : subctxt) {
     try {
       ((AbstractMetricsContext) ctxt).emitRecord(contextName, recordName, outRec);
       if (contextName == null || recordName == null || outRec == null) {
         throw new IOException(contextName + ":" + recordName + ":" + outRec);
       }
     } catch (IOException e) {
       LOG.warn("emitRecord failed: " + ctxt.getContextName(), e);
     }
   }
 }
 @Override
 @InterfaceAudience.Private
 public void init(String contextName, ContextFactory factory) {
   super.init(contextName, factory);
   int nKids;
   try {
     String sKids = getAttribute(ARITY_LABEL);
     nKids = Integer.parseInt(sKids);
   } catch (Exception e) {
     LOG.error(
         "Unable to initialize composite metric " + contextName + ": could not init arity", e);
     return;
   }
   for (int i = 0; i < nKids; ++i) {
     MetricsContext ctxt =
         MetricsUtil.getContext(String.format(SUB_FMT, contextName, i), contextName);
     if (null != ctxt) {
       subctxt.add(ctxt);
     }
   }
 }
 @Override
 @InterfaceAudience.Private
 public void init(String contextName, ContextFactory factory) {
   super.init(contextName, factory);
   parseAndSetPeriod(PERIOD_PROPERTY);
 }