Пример #1
0
 private void handleException(Exception e) {
   if (INTERRUPTED_EXCEPTION_TYPES.contains(e.getClass())) {
     LOG.info("Changes feed was interrupted");
   } else {
     LOG.error("Caught exception while listening to changes feed:", e);
   }
 }
Пример #2
0
  protected void generateView(Map<String, org.ektorp.support.DesignDocument.View> views, Field f) {
    DocumentReferences referenceMetaData = f.getAnnotation(DocumentReferences.class);
    if (referenceMetaData == null) {
      LOG.warn("No DocumentReferences annotation found in field: ", f.getName());
      return;
    }

    if (referenceMetaData.view().length() > 0) {
      LOG.debug("Skipping view generation for field {} as view is already specified", f.getName());
      return;
    }

    if (Set.class.isAssignableFrom(f.getType())) {
      generateSetBasedDocRefView(views, f, referenceMetaData);
    } else {
      throw new ViewGenerationException(
          String.format(
              "The type of the field: %s in %s annotated with DocumentReferences is not supported. (Must be assignable from java.util.Set)",
              f.getName(), f.getDeclaringClass()));
    }
  }
Пример #3
0
  protected void generateView(
      Map<String, org.ektorp.support.DesignDocument.View> views, Method me) {
    DocumentReferences referenceMetaData = me.getAnnotation(DocumentReferences.class);
    if (referenceMetaData == null) {
      LOG.warn("No DocumentReferences annotation found in method: ", me.getName());
      return;
    }
    if (!me.getName().startsWith("get")) {
      throw new ViewGenerationException(
          String.format(
              "The method: %s in %s annotated with DocumentReferences does not conform to the naming convention of 'getXxxx'",
              me.getName(), me.getDeclaringClass()));
    }

    if (Set.class.isAssignableFrom(me.getReturnType())) {
      generateSetBasedDocRefView(views, me, referenceMetaData);
    } else {
      throw new ViewGenerationException(
          String.format(
              "The return type of: %s in %s annotated with DocumentReferences is not supported. (Must be assignable from java.util.Set)",
              me.getName(), me.getDeclaringClass()));
    }
  }
Пример #4
0
 public void run() {
   try {
     String line = reader.readLine();
     while (shouldRun && line != null) {
       if (line.length() > 0) {
         handleChange(line);
       } else {
         handleHeartbeat();
       }
       line = reader.readLine();
     }
     String reason = !shouldRun ? "Cancelled" : "EOF";
     LOG.info("Changes feed stopped. Reason: " + reason);
   } catch (Exception e) {
     handleException(e);
   } finally {
     sendInterruptMarker();
     httpResponse.abort();
     try {
       reader.close();
     } catch (IOException e) {
     }
   }
 }
Пример #5
0
 @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
 private void sendInterruptMarker() {
   LOG.debug("Sending interrupt marker in order to interrupt feed consumer");
   changes.offer(INTERRUPT_MARKER);
 }
Пример #6
0
 public void cancel() {
   LOG.debug("Feed cancelled");
   shouldRun = false;
   thread.interrupt();
 }
Пример #7
0
 private void handleHeartbeat() {
   LOG.debug("Got heartbeat from DB");
 }