Package org.apache.flume

Examples of org.apache.flume.FlumeException


      List<Record> results = collector.getRecords();
      if (results.size() == 0) {
        return null;
      }
      if (results.size() > 1) {
        throw new FlumeException(getClass().getName() +
            " must not generate more than one output record per input event");
      }
      Event result = toEvent(results.get(0));   
      return result;
    }
View Full Code Here


      Map<String, String> headers = new HashMap();
      Map<String, Collection<Object>> recordMap = record.getFields().asMap();
      byte[] body = null;
      for (Map.Entry<String, Collection<Object>> entry : recordMap.entrySet()) {
        if (entry.getValue().size() > 1) {
          throw new FlumeException(getClass().getName()
              + " must not generate more than one output value per record field");
        }
        assert entry.getValue().size() != 0; // guava guarantees that
        Object firstValue = entry.getValue().iterator().next();
        if (Fields.ATTACHMENT_BODY.equals(entry.getKey())) {
          if (firstValue instanceof byte[]) {
            body = (byte[]) firstValue;
          } else if (firstValue instanceof InputStream) {
            try {
              body = ByteStreams.toByteArray((InputStream) firstValue);
            } catch (IOException e) {
              throw new FlumeException(e);
            }           
          } else {
            throw new FlumeException(getClass().getName()
                + " must non generate attachments that are not a byte[] or InputStream");
          }
        } else {
          headers.put(entry.getKey(), firstValue.toString());
        }
View Full Code Here

          providerClass = (Class<? extends KeyProvider.Builder>) c;
        } else {
          String errMessage = "Unable to instantiate Builder from " +
              keyProviderType;
          logger.error(errMessage);
          throw new FlumeException(errMessage);
        }
      } catch (ClassNotFoundException ex) {
        logger.error("Class not found: " + keyProviderType, ex);
        throw new FlumeException(ex);
      }
    }

    // build the builder
    KeyProvider.Builder provider;
    try {
      provider = providerClass.newInstance();
    } catch (InstantiationException ex) {
      String errMessage = "Cannot instantiate builder: " + keyProviderType;
      logger.error(errMessage, ex);
      throw new FlumeException(errMessage, ex);
    } catch (IllegalAccessException ex) {
      String errMessage = "Cannot instantiate builder: " + keyProviderType;
      logger.error(errMessage, ex);
      throw new FlumeException(errMessage, ex);
    }
    return provider.build(context);
  }
View Full Code Here

          providerClass = (Class<? extends CipherProvider>) c;
        } else {
          String errMessage = "Unable to instantiate provider from " +
              cipherProviderType;
          logger.error(errMessage);
          throw new FlumeException(errMessage);
        }
      } catch (ClassNotFoundException ex) {
        logger.error("Class not found: " + cipherProviderType, ex);
        throw new FlumeException(ex);
      }
    }
    try {
      return providerClass.newInstance();
    } catch (Exception ex) {
      String errMessage = "Cannot instantiate provider: " + cipherProviderType;
      logger.error(errMessage, ex);
      throw new FlumeException(errMessage, ex);
    }
  }
View Full Code Here

      for (Result r = rs.next(); r != null; r = rs.next()) {
        out = r.getValue(columnFamily.getBytes(), plCol.getBytes());

        if(i >= results.length - 1){
          rs.close();
          throw new FlumeException("More results than expected in the table." +
              "Expected = " + numEvents +". Found = " + i);
        }
        results[i++] = out;
        System.out.println(out);
      }
View Full Code Here

      for (Result r = rs.next(); r != null; r = rs.next()) {
        out = r.getValue(columnFamily.getBytes(), plCol.getBytes());

        if(i >= results.length - 1){
          rs.close();
          throw new FlumeException("More results than expected in the table." +
              "Expected = " + numEvents +". Found = " + i);
        }
        results[i++] = out;
        System.out.println(out);
      }
View Full Code Here

  public static boolean throwException = false;

  @Override
  public List<Row> getActions() throws FlumeException {
    if (throwException) {
      throw new FlumeException("Exception for testing");
    }
    return super.getActions();
  }
View Full Code Here

      logger.info("waiting on callback");
      latch.await();
      logger.info("callback received");
    } catch (InterruptedException e) {
      sinkCounter.incrementConnectionFailedCount();
      throw new FlumeException(
          "Interrupted while waiting for Hbase Callbacks", e);
    }
    if(fail.get()){
      sinkCounter.incrementConnectionFailedCount();
      client.shutdown();
      client = null;
      throw new FlumeException(
          "Could not start sink. " +
          "Table or column family does not exist in Hbase.");
    } else {
      open = true;
    }
View Full Code Here

        hbaseUser = HBaseSinkSecurityManager.login(config, null,
          kerberosPrincipal, kerberosKeytab);
      }
    } catch (Exception ex) {
      sinkCounter.incrementConnectionFailedCount();
      throw new FlumeException("Failed to login to HBase using "
        + "provided credentials.", ex);
    }
    try {
      table = runPrivileged(new PrivilegedExceptionAction<HTable>() {
        @Override
        public HTable run() throws Exception {
          HTable table = new HTable(config, tableName);
          table.setAutoFlush(false);
          // Flush is controlled by us. This ensures that HBase changing
          // their criteria for flushing does not change how we flush.
          return table;
        }
      });
    } catch (Exception e) {
      sinkCounter.incrementConnectionFailedCount();
      logger.error("Could not load table, " + tableName +
          " from HBase", e);
      throw new FlumeException("Could not load table, " + tableName +
          " from HBase", e);
    }
    try {
      if (!runPrivileged(new PrivilegedExceptionAction<Boolean>() {
        @Override
        public Boolean run() throws IOException {
          return table.getTableDescriptor().hasFamily(columnFamily);
        }
      })) {
        throw new IOException("Table " + tableName
                + " has no such column family " + Bytes.toString(columnFamily));
      }
    } catch (Exception e) {
      //Get getTableDescriptor also throws IOException, so catch the IOException
      //thrown above or by the getTableDescriptor() call.
      sinkCounter.incrementConnectionFailedCount();
      throw new FlumeException("Error getting column family from HBase."
              + "Please verify that the table " + tableName + " and Column Family, "
              + Bytes.toString(columnFamily) + " exists in HBase, and the"
              + " current user has permissions to access that table.", e);
    }
View Full Code Here

      if (table != null) {
        table.close();
      }
      table = null;
    } catch (IOException e) {
      throw new FlumeException("Error closing table.", e);
    }
    sinkCounter.incrementConnectionClosedCount();
    sinkCounter.stop();
  }
View Full Code Here

TOP

Related Classes of org.apache.flume.FlumeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.