Package org.apache.s4

Examples of org.apache.s4.TestListener$MyChannelHandler


        this.assignment = assignment;
    }

    @Inject
    private void resolveLocalPartitionId() {
        ClusterNode node = assignment.assignClusterNode();
        if (node != null) {
            localPartitionId = node.getPartition();
        }
    }
View Full Code Here


        bind(RemoteSenders.class).toInstance(Mockito.mock(RemoteSenders.class));
        bind(RemoteEmitters.class).toInstance(Mockito.mock(RemoteEmitters.class));
        bind(RemoteEmitterFactory.class).toInstance(Mockito.mock(RemoteEmitterFactory.class));
        bind(Clusters.class).toInstance(Mockito.mock(Clusters.class));
        Assignment mockedAssignment = Mockito.mock(Assignment.class);
        Mockito.when(mockedAssignment.assignClusterNode()).thenReturn(new ClusterNode(0, 0, "machine", "Task-0"));
        bind(Assignment.class).toInstance(mockedAssignment);
        Names.bindProperties(binder(), ImmutableMap.of("s4.cluster.name", "testCluster"));
    }
View Full Code Here

    @Override
    public boolean send(int partitionId, EventMessage eventMessage) {
        try {
            byte[] message = serDeser.serialize(eventMessage);
            ClusterNode node = nodes.get(partitionId);
            if (node == null) {
                LoggerFactory.getLogger(getClass()).error(
                        "Cannot send message to partition {} because this partition is not visible to this emitter",
                        partitionId);
                return false;
            }
            byte[] byteBuffer = new byte[message.length];
            System.arraycopy(message, 0, byteBuffer, 0, message.length);
            InetAddress inetAddress = inetCache.get(partitionId);
            if (inetAddress == null) {
                inetAddress = InetAddress.getByName(node.getMachineName());
                inetCache.put(partitionId, inetAddress);
            }
            DatagramPacket dp = new DatagramPacket(byteBuffer, byteBuffer.length, inetAddress, node.getPort());
            socket.send(dp);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

                if (process != null) {
                    int partition = Integer.parseInt(process.getSimpleField("partition"));
                    String host = process.getSimpleField("host");
                    int port = Integer.parseInt(process.getSimpleField("port"));
                    String taskId = process.getSimpleField("taskId");
                    ClusterNode node = new ClusterNode(partition, port, host, taskId);
                    nodes.add(node);
                }
            }

            app = new App();
View Full Code Here

        appPath = appDir + "/s4App";
        zkClient.subscribeDataChanges(appPath, new AppChangeListener());
    }

    public void deployApplication() throws DeploymentFailedException {
        ZNRecord appData = zkClient.readData(appPath);
        String uriString = appData.getSimpleField(S4R_URI);
        String appName = appData.getSimpleField("name");
        try {
            URI uri = new URI(uriString);

            // fetch application
            File localS4RFileCopy;
View Full Code Here

                }

            }
        });

        ZNRecord record2 = new ZNRecord(String.valueOf(System.currentTimeMillis()));
        record2.putSimpleField(DistributedDeploymentManager.S4R_URI, uriConsumer);
        zkClient.create("/s4/clusters/" + CONSUMER_CLUSTER + "/app/s4App", record2, CreateMode.PERSISTENT);
        // TODO check that consumer app is ready with a better way than checking stream consumers
        Assert.assertTrue(signalConsumerReady.await(20, TimeUnit.SECONDS));

        ZNRecord record1 = new ZNRecord(String.valueOf(System.currentTimeMillis()));
        record1.putSimpleField(DistributedDeploymentManager.S4R_URI, uriProducer);
        zkClient.create("/s4/clusters/" + PRODUCER_CLUSTER + "/app/s4App", record1, CreateMode.PERSISTENT);

        // that may be a bit long to complete...
        Assert.assertTrue(signalConsumptionComplete.await(30, TimeUnit.SECONDS));
View Full Code Here

        CommTestUtils.watchAndSignalCreation(AppConstants.INITIALIZED_ZNODE_1, signalAppInitialized,
                CommTestUtils.createZkClient());
        CommTestUtils.watchAndSignalCreation(AppConstants.INITIALIZED_ZNODE_1, signalAppStarted,
                CommTestUtils.createZkClient());

        ZNRecord record = new ZNRecord(String.valueOf(System.currentTimeMillis()));
        record.putSimpleField(DistributedDeploymentManager.S4R_URI, uri);
        zkClient.create("/s4/clusters/cluster1/app/s4App", record, CreateMode.PERSISTENT);

        Assert.assertTrue(signalAppInitialized.await(20, TimeUnit.SECONDS));
        Assert.assertTrue(signalAppStarted.await(20, TimeUnit.SECONDS));
View Full Code Here

                    s4rToDeploy = tmpS4R;
                }
            }

            final String uri = s4rToDeploy.toURI().toString();
            ZNRecord record = new ZNRecord(String.valueOf(System.currentTimeMillis()));
            record.putSimpleField(DistributedDeploymentManager.S4R_URI, uri);
            record.putSimpleField("name", deployArgs.appName);
            String deployedAppPath = "/s4/clusters/" + deployArgs.clusterName + "/app/s4App";
            if (zkClient.exists(deployedAppPath)) {
                ZNRecord readData = zkClient.readData(deployedAppPath);
                logger.error("Cannot deploy app [{}], because app [{}] is already deployed", deployArgs.appName,
                        readData.getSimpleField("name"));
                System.exit(1);
            }

            zkClient.create("/s4/clusters/" + deployArgs.clusterName + "/app/s4App", record, CreateMode.PERSISTENT);
            logger.info(
View Full Code Here

        }

        private void readStreamFromZk() throws Exception {
            List<String> consumerNodes = zkClient.getChildren(consumerPath);
            for (String node : consumerNodes) {
                ZNRecord consumer = zkClient.readData(consumerPath + "/" + node, true);
                consumers.add(consumer.getSimpleField("clusterName"));
            }

            List<String> producerNodes = zkClient.getChildren(producerPath);
            for (String node : producerNodes) {
                ZNRecord consumer = zkClient.readData(producerPath + "/" + node, true);
                producers.add(consumer.getSimpleField("clusterName"));
            }

            getAppNames();
        }
View Full Code Here

        }

        private static String getApp(String clusterName, ZkClient zkClient) {
            String appPath = "/s4/clusters/" + clusterName + "/app/s4App";
            if (zkClient.exists(appPath)) {
                ZNRecord appRecord = zkClient.readData("/s4/clusters/" + clusterName + "/app/s4App");
                return appRecord.getSimpleField("name");
            }
            return NONE;
        }
View Full Code Here

TOP

Related Classes of org.apache.s4.TestListener$MyChannelHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.