Package org.apache.s4.dispatcher.partitioner

Examples of org.apache.s4.dispatcher.partitioner.CompoundKeyInfo


        List<EventRecord> plainCompoundKeyList = null;
        if ((plainCompoundKeyList = get(Dispatcher.PARTITION_INFO_KEY,
                                        EMPTY_LIST)) != EMPTY_LIST) {
            for (EventRecord plainCompoundKeyInfo : plainCompoundKeyList) {
                CompoundKeyInfo compoundKeyInfo = new CompoundKeyInfo();
                compoundKeyInfo.setCompoundValue(plainCompoundKeyInfo.get("compoundValue",
                                                                          (String) null));
                compoundKeyInfo.setCompoundKey(plainCompoundKeyInfo.get("compoundKey",
                                                                        (String) null));
                compoundKeys.add(compoundKeyInfo);
                for (EventRecord plainKeyInfo : plainCompoundKeyInfo.get("keyInfoList",
                                                                         EMPTY_LIST)) {
                    KeyInfo keyInfo = new KeyInfo();
                    for (EventRecord plainKeyPathElement : plainKeyInfo.get("keyPathElementList",
                                                                            EMPTY_LIST)) {
                        String keyName = plainKeyPathElement.get("keyName",
                                                                 (String) null);
                        Integer index = plainKeyPathElement.get("index",
                                                                (Integer) null);

                        if (keyName != null) {
                            keyInfo.addElementToPath(keyName);
                        } else if (index != null) {
                            keyInfo.addElementToPath(index);
                        }
                    }
                    compoundKeyInfo.addKeyInfo(keyInfo);
                }
            }
        }
        if (debug) {
            for (CompoundKeyInfo compoundKeyInfo : compoundKeys) {
                System.out.println("CompoundKey: "
                        + compoundKeyInfo.getCompoundValue());
                for (KeyInfo keyInfo : compoundKeyInfo.getKeyInfoList()) {
                    String keyPath = "";
                    for (KeyPathElement keyPathElement : keyInfo.getKeyPath()) {
                        if (keyPathElement instanceof KeyPathElementIndex) {
                            keyPath += "["
                                    + ((KeyPathElementIndex) keyPathElement).getIndex()
View Full Code Here


        keyInfo.setValue(stringValue);

        // partition id is derived form string value, as usual
        int partitionId = (int) (h.hash(stringValue) % partCount);

        CompoundKeyInfo partitionInfo = new CompoundKeyInfo();
        partitionInfo.addKeyInfo(keyInfo);
        partitionInfo.setCompoundValue(stringValue);
        partitionInfo.setPartitionId(partitionId);

        List<CompoundKeyInfo> partitionInfoList = new ArrayList<CompoundKeyInfo>();
        partitionInfoList.add(partitionInfo);

        return partitionInfoList;
View Full Code Here

    public List<CompoundKeyInfo> partition(Hasher h, String delim, int partCount) {
        // send to all partitions
        List<CompoundKeyInfo> partitionInfoList = new ArrayList<CompoundKeyInfo>();

        for (int i = 0; i < partCount; ++i) {
            CompoundKeyInfo partitionInfo = new CompoundKeyInfo();
            partitionInfo.setPartitionId(i);
            partitionInfoList.add(partitionInfo);
        }

        return partitionInfoList;
    }
View Full Code Here

        int p = this.getRInfo().getPartition();
        List<CompoundKeyInfo> partitionInfoList = null;

        if (p >= 0 && p < partCount) {
            CompoundKeyInfo partitionInfo = new CompoundKeyInfo();
            partitionInfo.setPartitionId(p);

            partitionInfoList = new ArrayList<CompoundKeyInfo>();
            partitionInfoList.add(partitionInfo);
        }
View Full Code Here

        if (event instanceof SinglePERequest) {
            // Handle Requests to individual PEs
            if (keyInfoList.isEmpty())
                return;

            CompoundKeyInfo keyInfo = keyInfoList.get(0);

            String keyVal = keyInfo.getCompoundValue();

            ProcessingElement pe = p.lookupPE(keyVal);

            Response response = ((SinglePERequest) event).evaluate(pe);
            String stream = response.getRInfo().getStream();
View Full Code Here

        String results = new String(zk.getData("/results", false, null));
        Assert.assertEquals("be=2;da=2;doobie=5;not=1;or=1;to=2;", results);
    }

    public void injectSentence(String sentence) throws IOException {
        Event event = new Event();
        event.put("sentence", String.class, sentence);
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));
    }
View Full Code Here

        TestApp app = injector.getInstance(TestApp.class);
        app.count = 2; // One for the event, another for the timer
        app.init();
        app.start();

        app.testStream.receiveEvent(new EventMessage(APP_NAME, STREAM_NAME, app.getSerDeser().serialize(new Event())));

        /*
         * This must raise a timeout, since the onTime() event is blocked waiting for the onEvent() call to finish. If
         * it completes before the timeout, it means onEvent() and onTime() weren't synchronized
         */
 
View Full Code Here

        TestTimeWindowedApp app = injector.getInstance(TestTimeWindowedApp.class);
        app.init();
        app.start();

        for (int i = 0; i < NB_EVENTS; i++) {
            Event e = new Event();
            e.put("value", Integer.class, i);
            app.stream1.receiveEvent(new EventMessage(APP_NAME, STREAM_NAME, app.getSerDeser().serialize(e)));
        }

        try {
            Assert.assertTrue(signalAllEventsProcessed.await(30, TimeUnit.SECONDS));
View Full Code Here

        Injector injector = CoreTestUtils.createInjectorWithNonFailFastZKClients();

        TCPEmitter emitter = injector.getInstance(TCPEmitter.class);

        Event event = new Event();
        event.put("line", String.class, time1);
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));

        // check event processed
        Assert.assertTrue(signalEvent1Processed.await(5, TimeUnit.SECONDS));
View Full Code Here

        testCheckpointingConfiguration(S4AppWithCountBasedCheckpointing.class,
                CheckpointingModuleWithUnrespondingFetchingStorageBackend.class, false, "value1= ; value2=message2");
    }

    private void insertCheckpointInstruction(Injector injector, TCPEmitter emitter) {
        Event event;
        event = new Event();
        event.put("command", String.class, "checkpoint");
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));
    }
View Full Code Here

TOP

Related Classes of org.apache.s4.dispatcher.partitioner.CompoundKeyInfo

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.