samoa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicolas-kourtellis <...@git.apache.org>
Subject [GitHub] incubator-samoa pull request #64: SAMOA-65 JSON serializer/deserializer dedi...
Date Thu, 15 Jun 2017 13:32:35 GMT
Github user nicolas-kourtellis commented on a diff in the pull request:

    https://github.com/apache/incubator-samoa/pull/64#discussion_r122203064
  
    --- Diff: samoa-api/src/test/java/org/apache/samoa/streams/kafka/KafkaEntranceProcessorWithJsonTest.java
---
    @@ -0,0 +1,187 @@
    +/*
    + * Copyright 2017 The Apache Software Foundation.
    + *
    + * Licensed under the Apache License, Version 2.0 (the "License");
    + * you may not use this file except in compliance with the License.
    + * You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.samoa.streams.kafka;
    +
    +/*
    + * #%L
    + * SAMOA
    + * %%
    + * Copyright (C) 2014 - 2017 Apache Software Foundation
    + * %%
    + * Licensed under the Apache License, Version 2.0 (the "License");
    + * you may not use this file except in compliance with the License.
    + * You may obtain a copy of the License at
    + * 
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + * #L%
    + */
    +import com.google.gson.Gson;
    +import java.io.IOException;
    +import java.nio.charset.Charset;
    +import java.nio.file.Files;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Properties;
    +import java.util.Random;
    +import java.util.concurrent.ExecutionException;
    +import java.util.concurrent.TimeUnit;
    +import java.util.concurrent.TimeoutException;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +import org.apache.samoa.learners.InstanceContentEvent;
    +import org.junit.After;
    +import org.junit.AfterClass;
    +import org.junit.Before;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +import static org.junit.Assert.*;
    +import kafka.admin.AdminUtils;
    +import kafka.admin.RackAwareMode;
    +import kafka.server.KafkaConfig;
    +import kafka.server.KafkaServer;
    +import kafka.utils.MockTime;
    +import kafka.utils.TestUtils;
    +import org.apache.kafka.common.utils.Time;
    +import kafka.utils.ZKStringSerializer$;
    +import kafka.utils.ZkUtils;
    +import kafka.zk.EmbeddedZookeeper;
    +import org.I0Itec.zkclient.ZkClient;
    +import org.apache.kafka.clients.producer.KafkaProducer;
    +import org.apache.kafka.clients.producer.ProducerRecord;
    +import org.apache.samoa.instances.InstancesHeader;
    +
    +/**
    + *
    + * @author pwawrzyniak
    + * @author Jakub Jankowski
    + */
    +public class KafkaEntranceProcessorWithJsonTest {
    +
    +    private static final String ZKHOST = "127.0.0.1";
    +    private static final String BROKERHOST = "127.0.0.1";
    +    private static final String BROKERPORT = "9092";
    +    private static final String TOPIC_AVRO = "samoa_test-avro";
    +    private static final String TOPIC_JSON = "samoa_test-json";
    +    private static final int NUM_INSTANCES = 11111;
    +
    +    private static KafkaServer kafkaServer;
    +    private static EmbeddedZookeeper zkServer;
    +    private static ZkClient zkClient;
    +    private static String zkConnect;
    +    private static int TIMEOUT = 1000;
    +
    +    public KafkaEntranceProcessorWithJsonTest() {
    +    }
    +
    +    @BeforeClass
    +    public static void setUpClass() throws IOException {
    +        // setup Zookeeper
    +        zkServer = new EmbeddedZookeeper();
    +        zkConnect = ZKHOST + ":" + zkServer.port();
    +        zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    +        ZkUtils zkUtils = ZkUtils.apply(zkClient, false);
    +
    +        // setup Broker
    +        Properties brokerProps = new Properties();
    +        brokerProps.setProperty("zookeeper.connect", zkConnect);
    +        brokerProps.setProperty("broker.id", "0");
    +        brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    +        brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    +        KafkaConfig config = new KafkaConfig(brokerProps);
    +        Time mock = new MockTime();
    +        kafkaServer = TestUtils.createServer(config, mock);
    +
    +        // create topics
    +        AdminUtils.createTopic(zkUtils, TOPIC_AVRO, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
    --- End diff --
    
    Similar with previous comments


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message