当前位置: 首页>>代码示例>>Java>>正文


Java AbstractFunction1类代码示例

本文整理汇总了Java中scala.runtime.AbstractFunction1的典型用法代码示例。如果您正苦于以下问题:Java AbstractFunction1类的具体用法?Java AbstractFunction1怎么用?Java AbstractFunction1使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractFunction1类属于scala.runtime包,在下文中一共展示了AbstractFunction1类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveToCassandra

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
void saveToCassandra(List<DependencyLink> links) {
  Dependencies thrift = Dependencies.create(day, day /** ignored */, links);
  ByteBuffer blob = thrift.toThrift();

  log.info("Saving with day={}", dateStamp);
  CassandraConnector.apply(conf).withSessionDo(new AbstractFunction1<Session, Void>() {
    @Override public Void apply(Session session) {
      session.execute(QueryBuilder.insertInto(keyspace, "dependencies")
          .value("day", new Date(day))
          .value("dependencies", blob)
      );
      return null;
    }
  });
  log.info("Done");
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:17,代码来源:CassandraDependenciesJob.java

示例2: sendSpans

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@Override public void sendSpans(final List<byte[]> spans, final Callback callback) {
  Trace.letClear(new AbstractFunction0<Void>() {
    @Override public Void apply() {
      try {
        if (closeCalled) throw new IllegalStateException("closed");
        client.apply(makeRequest(spans)).respond(new AbstractFunction1<Try<Rep>, BoxedUnit>() {
          @Override public BoxedUnit apply(Try<Rep> result) {
            if (result.isReturn()) {
              callback.onComplete();
            } else {
              callback.onError(result.throwable());
            }
            return BoxedUnit.UNIT;
          }
        });
      } catch (Throwable e) {
        callback.onError(e);
        if (e instanceof Error) throw (Error) e;
      }
      return null;
    }
  });
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:24,代码来源:FinagleSender.java

示例3: filterMetaInf

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
public static ArtifactSource filterMetaInf(ArtifactSource source) {
    return source.filter(new AbstractFunction1<DirectoryArtifact, Object>() {
        @Override
        public Object apply(DirectoryArtifact dir) {
            // This is required to remove our maven packaging information
            if (dir.name().equals("META-INF")) {
                Optional<Artifact> nonMavenArtifact = JavaConverters
                        .asJavaCollectionConverter(dir.artifacts()).asJavaCollection().stream()
                        .filter(a -> !a.path().startsWith("META-INF/maven")).findAny();
                return nonMavenArtifact.isPresent();
            }
            return (!dir.path().equals("META-INF/maven"));
        }
    }, new AbstractFunction1<FileArtifact, Object>() {
        @Override
        public Object apply(FileArtifact arg0) {
            return true;
        }
    });
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:21,代码来源:ArtifactSourceUtils.java

示例4: asyncClose

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
public Future<Void> asyncClose() {
    DistributedLock lockToClose;
    synchronized (this) {
        if (null != lockAcquireFuture && !lockAcquireFuture.isDefined()) {
            FutureUtils.cancel(lockAcquireFuture);
        }
        lockToClose = readLock;
    }
    return Utils.closeSequence(scheduler, readAheadWorker, lockToClose)
            .flatMap(new AbstractFunction1<Void, Future<Void>>() {
        @Override
        public Future<Void> apply(Void result) {
            if (null != readAheadCache) {
                readAheadCache.clear();
            }
            if (null != handleCache) {
                handleCache.clear();
            }
            return BKLogReadHandler.super.asyncClose();
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:23,代码来源:BKLogReadHandler.java

示例5: deleteLedger

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
void deleteLedger(final long ledgerId) {
    final Future<Void> deleteFuture = bkc.deleteLedger(ledgerId, true);
    synchronized (ledgerDeletions) {
        ledgerDeletions.add(deleteFuture);
    }
    deleteFuture.onFailure(new AbstractFunction1<Throwable, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Throwable cause) {
            LOG.error("Error deleting ledger {} for ledger allocator {}, retrying : ",
                    new Object[] { ledgerId, allocatePath, cause });
            if (!isClosing()) {
                deleteLedger(ledgerId);
            }
            return BoxedUnit.UNIT;
        }
    }).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            synchronized (ledgerDeletions) {
                ledgerDeletions.remove(deleteFuture);
            }
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:26,代码来源:SimpleLedgerAllocator.java

示例6: doGetLogSegmentWriter

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
private Future<BKLogSegmentWriter> doGetLogSegmentWriter(final long firstTxid,
                                                         final boolean bestEffort,
                                                         final boolean rollLog,
                                                         final boolean allowMaxTxID) {
    if (encounteredError) {
        return Future.exception(new WriteException(bkDistributedLogManager.getStreamName(),
                "writer has been closed due to error."));
    }
    Future<BKLogSegmentWriter> writerFuture = asyncGetLedgerWriter(!disableRollOnSegmentError);
    if (null == writerFuture) {
        return rollLogSegmentIfNecessary(null, firstTxid, bestEffort, allowMaxTxID);
    } else if (rollLog) {
        return writerFuture.flatMap(new AbstractFunction1<BKLogSegmentWriter, Future<BKLogSegmentWriter>>() {
            @Override
            public Future<BKLogSegmentWriter> apply(BKLogSegmentWriter writer) {
                return rollLogSegmentIfNecessary(writer, firstTxid, bestEffort, allowMaxTxID);
            }
        });
    } else {
        return writerFuture;
    }
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:23,代码来源:BKAsyncLogWriter.java

示例7: flushAndCommit

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
Future<Long> flushAndCommit() {
    Future<BKLogSegmentWriter> writerFuture;
    synchronized (this) {
        if (null != this.rollingFuture) {
            writerFuture = this.rollingFuture;
        } else {
            writerFuture = getCachedLogWriterFuture();
        }
    }
    if (null == writerFuture) {
        return Future.value(getLastTxId());
    }
    return writerFuture.flatMap(new AbstractFunction1<BKLogSegmentWriter, Future<Long>>() {
        @Override
        public Future<Long> apply(BKLogSegmentWriter writer) {
            return writer.flushAndCommit();
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:20,代码来源:BKAsyncLogWriter.java

示例8: markEndOfStream

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
Future<Long> markEndOfStream() {
    final Stopwatch stopwatch = Stopwatch.createStarted();
    Future<BKLogSegmentWriter> logSegmentWriterFuture;
    synchronized (this) {
        logSegmentWriterFuture = this.rollingFuture;
    }
    if (null == logSegmentWriterFuture) {
        logSegmentWriterFuture = getLogSegmentWriterForEndOfStream();
    }

    return logSegmentWriterFuture.flatMap(new AbstractFunction1<BKLogSegmentWriter, Future<Long>>() {
        @Override
        public Future<Long> apply(BKLogSegmentWriter w) {
            return w.markEndOfStream();
        }
    }).addEventListener(new OpStatsListener<Long>(markEndOfStreamOpStatsLogger, stopwatch));
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:18,代码来源:BKAsyncLogWriter.java

示例9: asyncCloseAndComplete

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@Override
protected Future<Void> asyncCloseAndComplete() {
    Future<BKLogSegmentWriter> logSegmentWriterFuture;
    synchronized (this) {
        logSegmentWriterFuture = this.rollingFuture;
    }

    if (null == logSegmentWriterFuture) {
        return super.asyncCloseAndComplete();
    } else {
        return logSegmentWriterFuture.flatMap(new AbstractFunction1<BKLogSegmentWriter, Future<Void>>() {
            @Override
            public Future<Void> apply(BKLogSegmentWriter segmentWriter) {
                return BKAsyncLogWriter.super.asyncCloseAndComplete();
            }
        });
    }
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:19,代码来源:BKAsyncLogWriter.java

示例10: getLogLocation

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@Override
public Future<Optional<URI>> getLogLocation(final String logName) {
    if (duplicatedLogFound.get()) {
        return duplicatedLogException(duplicatedLogName.get());
    }
    URI location = log2Locations.get(logName);
    if (null != location) {
        return postStateCheck(Future.value(Optional.of(location)));
    }
    if (!forceCheckLogExistence) {
        Optional<URI> result = Optional.absent();
        return Future.value(result);
    }
    return postStateCheck(fetchLogLocation(logName).onSuccess(
            new AbstractFunction1<Optional<URI>, BoxedUnit>() {
                @Override
                public BoxedUnit apply(Optional<URI> uriOptional) {
                    if (uriOptional.isPresent()) {
                        log2Locations.putIfAbsent(logName, uriOptional.get());
                    }
                    return BoxedUnit.UNIT;
                }
            }));
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:25,代码来源:FederatedZKLogMetadataStore.java

示例11: asyncStartNewLogSegment

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
private Future<BKLogSegmentWriter> asyncStartNewLogSegment(final BKLogWriteHandler writeHandler,
                                                           final long startTxId,
                                                           final boolean allowMaxTxID) {
    return writeHandler.recoverIncompleteLogSegments()
            .flatMap(new AbstractFunction1<Long, Future<BKLogSegmentWriter>>() {
        @Override
        public Future<BKLogSegmentWriter> apply(Long lastTxId) {
            return writeHandler.asyncStartLogSegment(startTxId, false, allowMaxTxID)
                    .onSuccess(new AbstractFunction1<BKLogSegmentWriter, BoxedUnit>() {
                @Override
                public BoxedUnit apply(BKLogSegmentWriter newSegmentWriter) {
                    cacheLogWriter(newSegmentWriter);
                    return BoxedUnit.UNIT;
                }
            });
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:19,代码来源:BKAbstractLogWriter.java

示例12: executeOp

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@Override
protected Future<WriteResponse> executeOp(AsyncLogWriter writer,
                                          Sequencer sequencer,
                                          Object txnLock) {
    // write a control record if heartbeat is the first request of the recovered log segment.
    if (writeControlRecord) {
        long txnId;
        Future<DLSN> writeResult;
        synchronized (txnLock) {
            txnId = sequencer.nextId();
            writeResult = ((BKAsyncLogWriter) writer).writeControlRecord(new LogRecord(txnId, HEARTBEAT_DATA));
        }
        return writeResult.map(new AbstractFunction1<DLSN, WriteResponse>() {
            @Override
            public WriteResponse apply(DLSN value) {
                return ResponseUtils.writeSuccess().setDlsn(value.serialize(dlsnVersion));
            }
        });
    } else {
        return Future.value(ResponseUtils.writeSuccess());
    }
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:23,代码来源:HeartbeatOp.java

示例13: handleServiceTimeout

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
/**
 * Close the stream and schedule cache eviction at some point in the future.
 * We delay this as a way to place the stream in a probationary state--cached
 * in the proxy but unusable.
 * This mechanism helps the cluster adapt to situations where a proxy has
 * persistent connectivity/availability issues, because it keeps an affected
 * stream off the proxy for a period of time, hopefully long enough for the
 * issues to be resolved, or for whoop to kick in and kill the shard.
 */
synchronized void handleServiceTimeout(String reason) {
    if (StreamStatus.isUnavailable(status)) {
        return;
    }
    // Mark stream in error state
    setStreamInErrorStatus();

    // Async close request, and schedule eviction when its done.
    Future<Void> closeFuture = requestClose(reason, false /* dont remove */);
    closeFuture.onSuccess(new AbstractFunction1<Void, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Void result) {
            streamManager.scheduleRemoval(StreamImpl.this, streamProbationTimeoutMs);
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:27,代码来源:StreamImpl.java

示例14: lint

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@NotNull
public static Problems lint(final @NotNull Project project, @NotNull String workingDirectory,
                            @NotNull String file, @NotNull HaskellFile haskellFile) {
    final HaskellToolsConsole toolConsole = HaskellToolsConsole.get(project);
    final String hlintPath = ToolKey.HLINT_KEY.getPath(project);
    final String hlintFlags = ToolKey.HLINT_KEY.getFlags(project);
    if (hlintPath == null) return new Problems();

    return parseProblems(toolConsole, workingDirectory, hlintPath, hlintFlags, file, haskellFile).fold(
        new AbstractFunction1<ExecError, Problems>() {
            @Override
            public Problems apply(ExecError e) {
                toolConsole.writeError(ToolKey.HLINT_KEY, e.getMessage());
                NotificationUtil.displayToolsNotification(
                    NotificationType.ERROR, project, "hlint", e.getMessage()
                );
                return new Problems();
            }
        },
        FunctionUtil.<Problems>identity()
    );
}
 
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:23,代码来源:HLint.java

示例15: getVersion

import scala.runtime.AbstractFunction1; //导入依赖的package包/类
@NotNull
private static Either<ExecError, VersionTriple> getVersion(HaskellToolsConsole toolConsole, String workingDirectory, String hlintPath) {
    return EitherUtil.rightFlatMap(
        runHlint(toolConsole, workingDirectory, hlintPath, "--version"),
        new AbstractFunction1<String, Either<ExecError, VersionTriple>>() {
            @Override
            public Either<ExecError, VersionTriple> apply(String version) {
                Matcher m = HLINT_VERSION_REGEX.matcher(version);
                if (!m.find()) {
                    return new ExecError(
                        "Could not parse version from hlint: '" + version + "'",
                        null
                    ).toLeft();
                }
                return EitherUtil.right(new VersionTriple(
                    Integer.parseInt(m.group(1)),
                    Integer.parseInt(m.group(2)),
                    Integer.parseInt(m.group(3))
                ));
            }
        }
    );
}
 
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:24,代码来源:HLint.java


注:本文中的scala.runtime.AbstractFunction1类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。