Package com.linkedin.databus.core.data_model

Examples of com.linkedin.databus.core.data_model.LogicalSource


    PhysicalPartition pP = pStatConf1.getPhysicalPartition();
    _events = new TestDbusEvent [20];
    LogicalPartition lP = new LogicalPartition((short)0);
    for(int i=0; i<_events.length; i++) {
        _events[i] = new TestDbusEvent(i, scn,
                                       new LogicalSource(srcId, srcName+srcId),
                                       pS, pP, lP);
        switch(i) {
        case 4: srcId =2;
        break;
        case 9: srcId = 11;
View Full Code Here


    assertNotNull(buf,"cannot get by lSrcId" + lSrcId);


    // logical source 2 , default partition  - SAME BUFFER
    lSrcId = 2;
    LogicalSource lSource = new LogicalSource(lSrcId, "srcName2"); // correct source name, default partition 0
    DbusEventBufferAppendable buf1 = _eventBufferMult.getDbusEventBufferAppendable(lSource);
    assertNotNull(buf1, "cannot get buffer by lSource " + lSource);
    assertTrue(buf1 == buf, "buf and buf1 should be the same buffer");

    // logical source, different logical partition 1 - SAME BUFFER
View Full Code Here

    assertTrue(hasPP100);
    assertTrue(hasPP101);

    //test a subcription with a logical source
    DatabusSubscription sub3 =
        DatabusSubscription.createSimpleSourceSubscription(new LogicalSource(2, "srcName2"));

    DbusFilter filter3 = t._eventBuffer.constructFilters(Arrays.asList(sub3));
    assertNotNull(filter3);
    assertTrue(filter3 instanceof PhysicalPartitionDbusFilter);
    PhysicalPartitionDbusFilter ppfilter3 = (PhysicalPartitionDbusFilter)filter3;
    assertEquals(ppfilter3.getPhysicalPartition(), PhysicalPartition.ANY_PHYSICAL_PARTITION);
    DbusFilter ppfilter3_child = ppfilter3.getNestedFilter();
    assertNotNull(ppfilter3_child);
    assertTrue(ppfilter3_child instanceof LogicalSourceAndPartitionDbusFilter);
    LogicalSourceAndPartitionDbusFilter lsourceFilter3 = (LogicalSourceAndPartitionDbusFilter)ppfilter3_child;
    LogicalSourceAndPartitionDbusFilter.LogicalPartitionDbusFilter lpartFilter3_1 =
        lsourceFilter3.getSourceFilter(2);
    assertNotNull(lpartFilter3_1);
    assertTrue(lpartFilter3_1.isAllPartitionsWildcard());

    //test a subcription with a physical and logical partition
    DatabusSubscription sub4 =
        new DatabusSubscription(PhysicalSource.MASTER_PHISYCAL_SOURCE,
                                new PhysicalPartition(101, "multBufferTest2"),
                                new LogicalSourceId(new LogicalSource(2, "srcName2"), (short)2)
                                );

    DbusFilter filter4 = t._eventBuffer.constructFilters(Arrays.asList(sub4));
    assertNotNull(filter4);
    assertTrue(filter4 instanceof PhysicalPartitionDbusFilter);
View Full Code Here

    //read from one buffer and one source partition
    DatabusSubscription sub2 =
        new DatabusSubscription(PhysicalSource.MASTER_PHISYCAL_SOURCE,
                                new PhysicalPartition(101, "multBufferTest2"),
                                new LogicalSourceId(new LogicalSource(2, "srcName2"), (short)2)
                                );

    DbusFilter filter2 = t._eventBuffer.constructFilters(Arrays.asList(sub2));
    assertNotNull(filter2);

    CheckpointMult cpMult2 = new CheckpointMult();
    Checkpoint cp101 = new Checkpoint();
    cp101.init();
    cp101.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    cp101.setWindowScn(10L);
    cp101.setWindowOffset(-1);
    cpMult2.addCheckpoint(pp101, cp101);
    DbusEventBufferBatchReadable reader2 =
        t._eventBuffer.getDbusEventBufferBatchReadable(cpMult2, Arrays.asList(pk2), statsColls1);

    eventsRead = reader2.streamEvents(false, 1000000, Channels.newChannel(baos),
                                      Encoding.BINARY, filter2).getNumEventsStreamed();
    assertEquals(eventsRead, 6); //1 events + 1 eop + 3events + 1 eop

    baos.reset();
    statsCol1.reset();statsCol2.reset();

    //read all partitions for a source
    DatabusSubscription sub3 =
        new DatabusSubscription(PhysicalSource.MASTER_PHISYCAL_SOURCE,
                                PhysicalPartition.ANY_PHYSICAL_PARTITION,
                                LogicalSourceId.createAllPartitionsWildcard(new LogicalSource(2, "srcName2"))
                                );

    DbusFilter filter3 = t._eventBuffer.constructFilters(Arrays.asList(sub3));
    assertNotNull(filter3);
View Full Code Here

      _physicalToLogicalSrcMap.put(dbName,s);
    }

    s.add(srcName);
    IdNamePair pair = new IdNamePair(Long.valueOf(_maxSrcId), srcName);
    LogicalSource src = new LogicalSource(pair);
    List<LogicalSource> newSources = new ArrayList<LogicalSource>();
    newSources.add(src);
    _idNameRegistry.add(newSources);

    return _maxSrcId;
View Full Code Here

     return srcNames;
  }

  public short getSrcId(String srcName)
  {
    LogicalSource src = _idNameRegistry.getSource(srcName);

    if (src != null)
      return src.getId().shortValue();

    throw new RuntimeException("Unable to find the source id for the source name (" + srcName + ")");
  }
View Full Code Here

      relay = new DatabusRelayMain(httpRelayConfig.build(), pStaticConfigs);

      relay.start();

      // Insert one event into the relay.
      LogicalSource lsrc = new LogicalSource((int)lid, srcName);
      DbusEventBuffer buf = relay.getEventBuffer().getDbusEventBuffer(lsrc);
      byte [] schema = "abcdefghijklmnop".getBytes(Charset.defaultCharset());
      final long prevScn = 99;
      final long eventScn = 101;
      buf.start(prevScn);
View Full Code Here

    boolean first = true;
    for(DatabusSubscription sub :subs) {
      if(!first)
        sb.append(',');
      DatabusSubscription realSub = sub;
      LogicalSource ls = sub.getLogicalSource();
      if (!ls.idKnown() && !ls.isWildcard())
      {
        IdNamePair sourceEntry = sourceNameMap.get(ls.getName());
        if (null == sourceEntry)
        {
          //this should never happen
          throw new RuntimeException("FATAL! unable to find logical source " + ls.getName() + " in "
                                     + sourceNameMap);
        }
        realSub = new DatabusSubscription(
            sub.getPhysicalSource(), sub.getPhysicalPartition(),
            new LogicalSourceId(new LogicalSource(sourceEntry.getId().intValue(), ls.getName()),
                                sub.getLogicalPartition().getId()));
      }
      sb.append(realSub.toJsonString());
      first = false;
    }
View Full Code Here

    String separatorChar = "[";
    for (DatabusSubscription sub : getSubscriptions()) {
      shortSourcesListBuilder.append(separatorChar);
      PhysicalPartition p = sub.getPhysicalPartition();
      String sourceName = "AnySource";
      LogicalSource source = sub.getLogicalPartition().getSource();
      if (!source.isAllSourcesWildcard()) {
        sourceName = source.getName();
        int lastDotIdx = sourceName.lastIndexOf('.');
        if (lastDotIdx >= 0)
          sourceName = sourceName.substring(lastDotIdx + 1);
      }
      String partString = "AnyPPart_";
View Full Code Here

    return getOneBuffer(pPartition);
  }

  /** get appendable for single Logical source id (all partitions) */
  public DbusEventBufferAppendable getDbusEventBufferAppendable(int lSrcId) {
    LogicalSource lSource = _logicalId2LogicalSource.get(lSrcId);
    return getDbusEventBufferAppendable(lSource);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.data_model.LogicalSource

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.