/** * Util method that checks that output schema contains only double types and returns list of field names. * * @param mdl Pipeline model. * @return List of field names. */ private List<String> checkAndGetInputSchema(PipelineModel mdl) { Transformer firstTransformer = mdl.transformers().head(); StructType inputSchema = firstTransformer.inputSchema(); List<StructField> input = new ArrayList<>(JavaConverters.seqAsJavaListConverter(inputSchema.fields()).asJava()); List<String> schema = new ArrayList<>(); for (StructField field : input) { String fieldName = field.name(); schema.add(field.name()); if (!ScalarType.Double().base().equals(field.dataType().base())) throw new IllegalArgumentException("Parser supports only double types [name=" + fieldName + ",type=" + field.dataType() + "]"); } return schema; } }
@Override public int getLeaderToShutDown(String topic) throws Exception { ZkUtils zkUtils = getZkUtils(); try { PartitionMetadata firstPart = null; do { if (firstPart != null) { LOG.info("Unable to find leader. error code {}", firstPart.errorCode()); // not the first try. Sleep a bit Thread.sleep(150); } Seq<PartitionMetadata> partitionMetadata = AdminUtils.fetchTopicMetadataFromZk(topic, zkUtils).partitionsMetadata(); firstPart = partitionMetadata.head(); } while (firstPart.errorCode() != 0); return firstPart.leader().get().id(); } finally { zkUtils.close(); } }
private void cleanLogs() { try { FileUtils.deleteDirectory(new File(kafkaConfig.logDirs().head())); } catch (IOException e) { logger.info("Error while removing kafka logs", e); throw new IllegalStateException(e); } }
private void cleanLogs() { try { FileUtils.deleteDirectory(new File(kafkaConfig.logDirs().head())); } catch (IOException e) { logger.info("Error while removing kafka logs", e); throw new IllegalStateException(e); } }
private static void checkCircularModuleImports(Module mainModule, scala.collection.Seq<Module> visitedModules) { if (visitedModules.contains(mainModule)) { String msg = "Found circularity in module imports: "; for (Module m : mutable(visitedModules)) { // JavaConversions.seqAsJavaList(visitedModules) msg += m.getName() + " < "; } msg += visitedModules.head().getName(); throw KEMException.compilerError(msg); } }
private long getTopicLogSize(String topic, int pid) { Option<Object> o = ZkUtils.getLeaderForPartition(zkClient, topic, pid); if (o.isEmpty() || o.get() == null) { log.error("No broker for partition %s - %s", topic, pid); return 0; } Integer leaderId = Int.unbox(o.get()); SimpleConsumer consumer = consumerMap.get(leaderId); if (consumer == null) { consumer = createSimpleConsumer(leaderId); } // createSimpleConsumer may fail. if (consumer == null) { return 0; } consumerMap.put(leaderId, consumer); TopicAndPartition topicAndPartition = new TopicAndPartition(topic, pid); PartitionOffsetRequestInfo requestInfo = new PartitionOffsetRequestInfo(OffsetRequest.LatestTime(), 1); OffsetRequest request = new OffsetRequest( new Map1<TopicAndPartition, PartitionOffsetRequestInfo>(topicAndPartition, requestInfo), 0, Request.OrdinaryConsumerId() ); OffsetResponse response = consumer.getOffsetsBefore(request); PartitionOffsetsResponse offsetsResponse = response.partitionErrorAndOffsets().get(topicAndPartition).get(); return scala.Long.unbox(offsetsResponse.offsets().head()); }
@Override public int getLeaderToShutDown(String topic) throws Exception { ZkUtils zkUtils = getZkUtils(); try { PartitionMetadata firstPart = null; do { if (firstPart != null) { LOG.info("Unable to find leader. error code {}", firstPart.errorCode()); // not the first try. Sleep a bit Thread.sleep(150); } Seq<PartitionMetadata> partitionMetadata = AdminUtils.fetchTopicMetadataFromZk(topic, zkUtils).partitionsMetadata(); firstPart = partitionMetadata.head(); } while (firstPart.errorCode() != 0); return firstPart.leader().get().id(); } finally { zkUtils.close(); } }
@Override public int getLeaderToShutDown(String topic) throws Exception { ZkUtils zkUtils = getZkUtils(); try { PartitionMetadata firstPart = null; do { if (firstPart != null) { LOG.info("Unable to find leader. error code {}", firstPart.errorCode()); // not the first try. Sleep a bit Thread.sleep(150); } Seq<PartitionMetadata> partitionMetadata = AdminUtils.fetchTopicMetadataFromZk(topic, zkUtils).partitionsMetadata(); firstPart = partitionMetadata.head(); } while (firstPart.errorCode() != 0); return firstPart.leader().get().id(); } finally { zkUtils.close(); } }
Production p = (Production) s; assert p.items().head() instanceof Terminal || p.items().head() instanceof RegexTerminal; assert p.items().last() instanceof Terminal || p.items().last() instanceof RegexTerminal; final ProductionItem body; Seq<ProductionItem> pi = Seq(p.items().head(), optDots, body, optDots, p.items().last()); Production p1 = Production(p.klabel().get(), p.sort(), pi, p.att()); Production p2 = Production(Sorts.Cell(), Seq(NonTerminal(p.sort())));