final String akkaHostname = AkkaUtils.getAddress(actorSystem).host().get(); final int akkaPort = (Integer) AkkaUtils.getAddress(actorSystem).port().get(); highAvailabilityServices, metricRegistry, webMonitor == null ? Option.empty() : Option.apply(webMonitor.getRestAddress()), new Some<>(JobMaster.JOB_MANAGER_NAME), Option.<String>empty(), getJobManagerClass(),
@Override public TopicMetadataResponse send(TopicMetadataRequest request) { java.util.List<String> topics = request.topics(); TopicMetadata[] topicMetadataArray = new TopicMetadata[topics.size()]; for (int i = 0; i < topicMetadataArray.length; i++) { String topic = topics.get(i); if (!topic.equals(topicName)) { topicMetadataArray[i] = new TopicMetadata(topic, null, Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); } else { PartitionMetadata[] partitionMetadataArray = new PartitionMetadata[partitionCount]; for (int j = 0; j < partitionCount; j++) { java.util.List<BrokerEndPoint> emptyJavaList = Collections.emptyList(); List<BrokerEndPoint> emptyScalaList = JavaConversions.asScalaBuffer(emptyJavaList).toList(); partitionMetadataArray[j] = new PartitionMetadata(j, Some.apply(brokerArray[partitionLeaderIndices[j]]), emptyScalaList, emptyScalaList, Errors.NONE.code()); } Seq<PartitionMetadata> partitionsMetadata = List.fromArray(partitionMetadataArray); topicMetadataArray[i] = new TopicMetadata(topic, partitionsMetadata, Errors.NONE.code()); } } Seq<BrokerEndPoint> brokers = List.fromArray(brokerArray); Seq<TopicMetadata> topicsMetadata = List.fromArray(topicMetadataArray); return new TopicMetadataResponse(new kafka.api.TopicMetadataResponse(brokers, topicsMetadata, -1)); } }
@Override public Node nextNode(Long capability, Long persistentCapability){ Option<com.linkedin.norbert.cluster.Node> node = loadBalancer.nextNode(new Some<Long>(capability.longValue()), new Some<Long>(persistentCapability.longValue())); if(node.isDefined()) return JavaNode.apply(node.get()); else return null; }
ActorSystem as = AkkaUtils.createActorSystem( new Configuration(), new Some<scala.Tuple2<String, Object>>(new scala.Tuple2<String, Object>(addr.getHostAddress(), port))); as.shutdown();
/** the {@link OdinDocument} that represents the jCas */ public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } }
CurrentTimeProvider timeProvider = mock(CurrentTimeProvider.class); Some some = new Some(); some.setTimeProvider(timeProvider); when(timeProvider.getCurrentDate).thenReturn(mock(Date.class)); //Invoke you method some.publicFun(); //Put assert and verify here
public static void main(String[] args) throws Exception { EntityManagerFactory emf = Persistence.createEntityManagerFactory("someClientPU"); EntityManager em = emf.createEntityManager(); SomeDAO someDAO = new SomeDAOClient(em); try { Some some = new Some(); some.setFoo("foo"); someDAO.save(some); } finally { em.close(); emf.close(); } }
/** * @see Buf.Utf8#unapply(Buf) */ public static String asUtf8String(Buf buf) { return Buf.Utf8$.MODULE$.unapply(buf).get(); }
@Override public Node nextNode(Long capability, Long persistentCapability){ Option<com.linkedin.norbert.cluster.Node> node = loadBalancer.nextNode(new Some<Long>(capability.longValue()), new Some<Long>(persistentCapability.longValue())); if(node.isDefined()) return JavaNode.apply(node.get()); else return null; }
Option numFiles = parallelism == -1 ? Option.apply(null) : new Some(parallelism); final String timeZone = properties.getString(CsvOptions.OPTIONAL_TIME_ZONE); final TimeZone tz = (timeZone == null) ? TimeZone.getTimeZone("UTC") : TimeZone.getTimeZone(timeZone); new CsvTableSink( path, Option.apply(fieldDelim), Option.apply(lineDelim), Option.apply(quoteCharacter), numFiles,
@Before public void setUp() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment(); env.generateSequence(1, 1000).output(new DiscardingOutputFormat<Long>()); Plan plan = env.createProgramPlan(); JobWithJars jobWithJars = new JobWithJars(plan, Collections.<URL>emptyList(), Collections.<URL>emptyList()); program = mock(PackagedProgram.class); when(program.getPlanWithJars()).thenReturn(jobWithJars); final int freePort = NetUtils.getAvailablePort(); config = new Configuration(); config.setString(JobManagerOptions.ADDRESS, "localhost"); config.setInteger(JobManagerOptions.PORT, freePort); config.setString(AkkaOptions.ASK_TIMEOUT, AkkaOptions.ASK_TIMEOUT.defaultValue()); try { scala.Tuple2<String, Object> address = new scala.Tuple2<String, Object>("localhost", freePort); jobManagerSystem = AkkaUtils.createActorSystem(config, new scala.Some<scala.Tuple2<String, Object>>(address)); } catch (Exception e) { e.printStackTrace(); fail("Setup of test actor system failed."); } }
/** the {@link OdinDocument} that represents the jCas */ public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } }
/** * @see Buf.Utf8#unapply(Buf) */ public static String asUtf8String(Buf buf) { return Buf.Utf8$.MODULE$.unapply(buf).get(); }
final String akkaHostname = AkkaUtils.getAddress(actorSystem).host().get(); final int akkaPort = (Integer) AkkaUtils.getAddress(actorSystem).port().get(); highAvailabilityServices, metricRegistry, webMonitor == null ? Option.empty() : Option.apply(webMonitor.getRestAddress()), new Some<>(JobMaster.JOB_MANAGER_NAME), Option.<String>empty(), getJobManagerClass(),
public static ActorSystem startJobClientActorSystem(Configuration config) throws IOException { LOG.info("Starting JobClient actor system"); Option<Tuple2<String, Object>> remoting = new Some<>(new Tuple2<String, Object>("", 0)); // start a remote actor system to listen on an arbitrary port ActorSystem system = AkkaUtils.createActorSystem(config, remoting); Address address = system.provider().getDefaultAddress(); String hostAddress = address.host().isDefined() ? NetUtils.ipAddressToUrlString(InetAddress.getByName(address.host().get())) : "(unknown)"; int port = address.port().isDefined() ? ((Integer) address.port().get()) : -1; LOG.info("Started JobClient actor system at " + hostAddress + ':' + port); return system; }
@Override public Some<String> modelPackage() { return new Some<>(BASE_PACKAGE + ".model"); }
/** * Invoked when a handler or resource is not found. * <p> * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content. * <p> * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template. * * @param request The request that no handler was found to handle. * @param message A message, which is not used by the default implementation. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onNotFound(RequestHeader request, String message) { if (environment.isProd()) { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render( request.method(), request.uri(), request.asScala()))); } else { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render( request.method(), request.uri(), Some.apply(routes.get()), request.asScala() ))); } }
final String akkaHostname = AkkaUtils.getAddress(actorSystem).host().get(); final int akkaPort = (Integer) AkkaUtils.getAddress(actorSystem).port().get(); highAvailabilityServices, metricRegistry, webMonitor == null ? Option.empty() : Option.apply(webMonitor.getRestAddress()), new Some<>(JobMaster.JOB_MANAGER_NAME), Option.<String>empty(), getJobManagerClass(),