com.twitter.util.Future.addEventListener()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中com.twitter.util.Future.addEventListener()方法的一些代码示例,展示了Future.addEventListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.addEventListener()方法的具体详情如下:
包路径:com.twitter.util.Future
类名称:Future
方法名:addEventListener

Future.addEventListener介绍

暂无

代码示例

代码示例来源:origin: twitter/distributedlog

@Override
  public void run() {
    if (null != store.listeners.get(logSegmentsPath)) {
      store.getLogSegmentNames(logSegmentsPath, store).addEventListener(this);
    } else {
      logger.debug("Log segments listener for {} has been removed.", logSegmentsPath);
    }
  }
}

代码示例来源:origin: twitter/distributedlog

void readLoop() {
  if (!running) {
    return;
  }
  logReaders[streamIdx].readBulk(10).addEventListener(this);
}

代码示例来源:origin: twitter/distributedlog

@Override
public void run() {
  this.reader.readNext().addEventListener(this);
}

代码示例来源:origin: twitter/distributedlog

private void getCachedSubNamespacesAndCreateLog(final String logName,
                        final Promise<URI> createPromise) {
  getCachedSubNamespaces().addEventListener(new FutureEventListener<Set<URI>>() {
    @Override
    public void onSuccess(Set<URI> uris) {
      findSubNamespaceToCreateLog(logName, uris, createPromise);
    }
    @Override
    public void onFailure(Throwable cause) {
      createPromise.setException(cause);
    }
  });
}

代码示例来源:origin: twitter/distributedlog

@Override
public void run() {
  fetchSubNamespaces(this).addEventListener(this);
}

代码示例来源:origin: twitter/distributedlog

private void fetchSubNamespacesAndCreateLog(final String logName,
                      final Promise<URI> createPromise) {
  fetchSubNamespaces(null).addEventListener(new FutureEventListener<Set<URI>>() {
    @Override
    public void onSuccess(Set<URI> uris) {
      findSubNamespaceToCreateLog(logName, uris, createPromise);
    }
    @Override
    public void onFailure(Throwable cause) {
      createPromise.setException(cause);
    }
  });
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void run() {
    if (interrupted) {
      logger.debug("ListFutureProcessor is interrupted.");
      return;
    }
    if (!itemsIter.hasNext()) {
      promise.setValue(results);
      return;
    }
    processFunc.apply(itemsIter.next()).addEventListener(this);
  }
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void onSuccess(LogRecordWithDLSN record) {
    System.out.println("Received record " + record.getDlsn());
    System.out.println("\"\"\"");
    System.out.println(new String(record.getPayload(), UTF_8));
    System.out.println("\"\"\"");
    reader.readNext().addEventListener(this);
  }
};

代码示例来源:origin: twitter/distributedlog

private Future<BKLogSegmentWriter> getLogSegmentWriter(long firstTxid,
                            boolean bestEffort,
                            boolean rollLog,
                            boolean allowMaxTxID) {
  Stopwatch stopwatch = Stopwatch.createStarted();
  return doGetLogSegmentWriter(firstTxid, bestEffort, rollLog, allowMaxTxID)
      .addEventListener(new OpStatsListener<BKLogSegmentWriter>(getWriterOpStatsLogger, stopwatch));
}

代码示例来源:origin: twitter/distributedlog

/**
 * Write a log record to the stream.
 *
 * @param record single log record
 */
@Override
public Future<DLSN> write(final LogRecord record) {
  final Stopwatch stopwatch = Stopwatch.createStarted();
  return asyncWrite(record, true)
      .addEventListener(new OpStatsListener<DLSN>(writeOpStatsLogger, stopwatch));
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void onSuccess(LogRecordWithDLSN record) {
    System.out.println("Received record " + record.getDlsn());
    System.out.println("\"\"\"");
    System.out.println(new String(record.getPayload(), UTF_8));
    System.out.println("\"\"\"");
    long diffInMilliseconds = System.currentTimeMillis() - record.getTransactionId();
    if (!caughtup.get() && diffInMilliseconds < 2000) {
      System.out.println("Reader caught with latest data");
      caughtup.set(true);
    }
    reader.readNext().addEventListener(this);
  }
};

代码示例来源:origin: twitter/distributedlog

@Override
  public void onSuccess(LogRecordWithDLSN record) {
    System.out.println("Received record " + record.getDlsn());
    System.out.println("\"\"\"");
    System.out.println(new String(record.getPayload(), UTF_8));
    System.out.println("\"\"\"");
    lastDLSN.set(record.getDlsn());
    reader.readNext().addEventListener(this);
  }
};

代码示例来源:origin: twitter/distributedlog

@Override
public void process(WatchedEvent watchedEvent) {
  if (Event.EventType.None == watchedEvent.getType() &&
      Event.KeeperState.Expired == watchedEvent.getState()) {
    scheduleTask(this, conf.getZKSessionTimeoutMilliseconds());
    return;
  }
  if (Event.EventType.NodeChildrenChanged == watchedEvent.getType()) {
    // fetch the namespace
    fetchSubNamespaces(this).addEventListener(this);
  }
}

代码示例来源:origin: twitter/distributedlog

@Override
  public void onSuccess(LogRecordWithDLSN record) {
    System.out.println("Received record " + record.getDlsn() + " from stream " + reader.getStreamName());
    System.out.println("\"\"\"");
    System.out.println(new String(record.getPayload(), UTF_8));
    System.out.println("\"\"\"");
    reader.readNext().addEventListener(this);
  }
};

代码示例来源:origin: twitter/distributedlog

synchronized String sendWriteToStream(int streamId) {
  String stream = getStream(streamId);
  client.writeRecordSet(stream, recordSet)
      .addEventListener(this);
  return stream;
}

代码示例来源:origin: twitter/distributedlog

private static class SingleEntryScanContext extends ScanContext {
  SingleEntryScanContext(long entryId) {
    super(entryId, entryId, 1, 1, true, true, false, new AtomicInteger(0));
  }
}

代码示例来源:origin: twitter/distributedlog

/**
 * Write many log records to the stream. The return type here is unfortunate but its a direct result
 * of having to combine FuturePool and the asyncWriteBulk method which returns a future as well. The
 * problem is the List that asyncWriteBulk returns can't be materialized until getLogSegmentWriter
 * completes, so it has to be wrapped in a future itself.
 *
 * @param records list of records
 */
@Override
public Future<List<Future<DLSN>>> writeBulk(final List<LogRecord> records) {
  final Stopwatch stopwatch = Stopwatch.createStarted();
  return Future.value(asyncWriteBulk(records))
      .addEventListener(new OpStatsListener<List<Future<DLSN>>>(bulkWriteOpStatsLogger, stopwatch));
}

代码示例来源:origin: twitter/distributedlog

public Future<DLSN> write(byte[] data) {
  requestPos += data.length;
  Future<DLSN> writeResult = logWriter.write(new LogRecord(requestPos, data));
  return writeResult.addEventListener(new WriteCompleteListener(requestPos));
}

代码示例来源:origin: twitter/distributedlog

@Override
public void onSuccess(LogRecordWithDLSN record) {
  readRecords.add(record);
  r.readNext().addEventListener(this);
}

代码示例来源:origin: twitter/distributedlog

private void readNext() {
  Future<LogRecordWithDLSN> record = reader.readNext();
  record.addEventListener(this);
}

相关文章