Package io.s4.dispatcher.partitioner

Examples of io.s4.dispatcher.partitioner.CompoundKeyInfo


   @Test
   public void testCloneAndInitialize() {
       MockPE prototype = new MockPE();
       prototype.setInitMethod("testInitialize");
      
       PrototypeWrapper prototypeWrapper = new PrototypeWrapper(prototype, new WallClock());

       assertEquals(0, prototype.getInitializeCount());
       MockPE instance = (MockPE)prototypeWrapper.getPE("asd");
       assertNotNull(instance);
      
View Full Code Here


        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

        Schema schema = new Schema(KeyValue.class);
        JSONObject jsonRecord = new JSONObject("{key:" + keyValue.getKey()
                + ",value:" + keyValue.getValue() + "}");
        Object event = LoadGenerator.makeRecord(jsonRecord, schema);
        CompoundKeyInfo compoundKeyInfo = new CompoundKeyInfo();
        compoundKeyInfo.setCompoundKey("key");
        compoundKeyInfo.setCompoundValue("value");
        List<CompoundKeyInfo> compoundKeyInfos = new ArrayList<CompoundKeyInfo>();
        compoundKeyInfos.add(compoundKeyInfo);
        EventWrapper eventWrapper = new EventWrapper(streamName, event,
                compoundKeyInfos);
        eventEmitter.emit(partitionId, eventWrapper);
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();

            AbstractPE pe = p.lookupPE(keyVal);

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

TOP

Related Classes of io.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.