Package com.linkedin.databus2.relay

Examples of com.linkedin.databus2.relay.GoldenGateEventProducer


      Assert.assertEquals("Number of Source batches", 2, result.size());
      Assert.assertEquals("Result Set Size", result.get(0).getDbUpdatesSet().size(), 1);
      Assert.assertEquals("Result Set Size", result.get(1).getDbUpdatesSet().size(), 1);

      DBUpdateImage dbi = result.get(0).getDbUpdatesSet().iterator().next();
      DBUpdateImage expDbi = newDbUpdates.get(0).getDbUpdatesSet().iterator().next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      String k = (String) dbi.getGenericRecord().get("name1");
      String v = (String) dbi.getGenericRecord().get("name2");
      String expK = (String) expDbi.getGenericRecord().get("name1");
      String expV = (String) expDbi.getGenericRecord().get("name2");
      Assert.assertEquals("Key Check", expK, k);
      Assert.assertEquals("Val Check", expV, v);

      dbi = result.get(1).getDbUpdatesSet().iterator().next();
      expDbi = newDbUpdates.get(1).getDbUpdatesSet().iterator().next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      k = (String) dbi.getGenericRecord().get("name1");
      v = (String) dbi.getGenericRecord().get("name2");
      expK = (String) expDbi.getGenericRecord().get("name1");
      expV = (String) expDbi.getGenericRecord().get("name2");
      Assert.assertEquals("Key Check", expK, k);
      Assert.assertEquals("Val Check", expV, v);
    }

    // Case when 2 txn have same source but different keys
    {
      String key = "key1";
      String oldVal = "val1";
      Map<String, String> keyVals1 = new HashMap<String, String>();
      keyVals1.put(key, oldVal);
      Map<String, String> keyVals2 = new HashMap<String, String>();
      key = "key2";
      String newVal = "val2";
      keyVals2.put(key, newVal);
      List<TransactionState.PerSourceTransactionalUpdate> oldDbUpdates =
          generateUpdatesForSchema2(sourceIds, keyVals1, scn);
      List<TransactionState.PerSourceTransactionalUpdate> newDbUpdates =
          generateUpdatesForSchema2(sourceIds, keyVals2, scn);
      List<TransactionState.PerSourceTransactionalUpdate> result =
          DBUpdatesMergeUtils.mergeTransactionData(newDbUpdates, oldDbUpdates);

      Assert.assertEquals("Number of Source batches", 2, result.size());
      Assert.assertEquals("Result Set Size", result.get(0).getDbUpdatesSet().size(), 2);
      Assert.assertEquals("Result Set Size", result.get(1).getDbUpdatesSet().size(), 2);

      Iterator<DBUpdateImage> itr = result.get(0).getDbUpdatesSet().iterator();
      DBUpdateImage dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      String k = (String) dbi.getGenericRecord().get("name1");
      String v = (String) dbi.getGenericRecord().get("name2");
      dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      String k2 = (String) dbi.getGenericRecord().get("name1");
      String v2 = (String) dbi.getGenericRecord().get("name2");

      if (keyVals1.containsKey(k))
      {
        Assert.assertEquals("Val Check", keyVals1.get(k), v);
        Assert.assertEquals("Val Check 2", keyVals2.get(k2), v2);
      }
      else
      {
        Assert.assertEquals("Val Check", keyVals2.get(k), v);
        Assert.assertEquals("Val Check 2", keyVals1.get(k2), v2);
      }

      itr = result.get(1).getDbUpdatesSet().iterator();
      dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      k = (String) dbi.getGenericRecord().get("name1");
      v = (String) dbi.getGenericRecord().get("name2");
      dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      k2 = (String) dbi.getGenericRecord().get("name1");
      v2 = (String) dbi.getGenericRecord().get("name2");

      if (keyVals1.containsKey(k))
      {
        Assert.assertEquals("Val Check", keyVals1.get(k), v);
        Assert.assertEquals("Val Check 2", keyVals2.get(k2), v2);
      }
      else
      {
        Assert.assertEquals("Val Check", keyVals2.get(k), v);
        Assert.assertEquals("Val Check 2", keyVals1.get(k2), v2);
      }
    }

    // Case when 2 txns have different sources
    {
      String key = "key1";
      String oldVal = "val1";
      Map<String, String> keyVals1 = new HashMap<String, String>();
      keyVals1.put(key, oldVal);
      Map<String, String> keyVals2 = new HashMap<String, String>();
      key = "key2";
      String newVal = "val2";
      keyVals2.put(key, newVal);
      List<TransactionState.PerSourceTransactionalUpdate> oldDbUpdates =
          generateUpdatesForSchema2(new short[] { sourceIds[0] }, keyVals1, scn);
      List<TransactionState.PerSourceTransactionalUpdate> newDbUpdates =
          generateUpdatesForSchema2(new short[] { sourceIds[1] }, keyVals2, scn);
      List<TransactionState.PerSourceTransactionalUpdate> result =
          DBUpdatesMergeUtils.mergeTransactionData(newDbUpdates, oldDbUpdates);

      Assert.assertEquals("Number of Source batches", 2, result.size());
      Assert.assertEquals("Result Set Size", result.get(0).getDbUpdatesSet().size(), 1);
      Assert.assertEquals("Result Set Size", result.get(1).getDbUpdatesSet().size(), 1);

      Iterator<DBUpdateImage> itr = result.get(0).getDbUpdatesSet().iterator();
      DBUpdateImage dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      String k = (String) dbi.getGenericRecord().get("name1");
      String v = (String) dbi.getGenericRecord().get("name2");
      Assert.assertEquals("Val Check", keyVals1.get(k), v);

      itr = result.get(1).getDbUpdatesSet().iterator();
      dbi = itr.next();
      Assert.assertEquals("SCN Check", scn, dbi.getScn());
      k = (String) dbi.getGenericRecord().get("name1");
      v = (String) dbi.getGenericRecord().get("name2");
      Assert.assertEquals("Val Check", keyVals2.get(k), v);
    }
  }
View Full Code Here


    Schema s = Schema.parse(avroSchema);
    GenericRecord gr = new GenericData.Record(s);
    gr.put("name", "phani");

    DBUpdateImage dbi = new DBUpdateImage(keyPairs, scn, gr, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT,false);
    db.add(dbi);
    TransactionState.PerSourceTransactionalUpdate dbUpdate = new TransactionState.PerSourceTransactionalUpdate(
        sourceId, db);
    dbUpdates.add(dbUpdate);
View Full Code Here

        keyPairs.add(kp);
        GenericRecord gr = new GenericData.Record(s);
        gr.put(keyName, k);
        gr.put(valName, keyVals.get(k));

        DBUpdateImage dbi = new DBUpdateImage(keyPairs, scn, gr, s,
                                              DbUpdateState.DBUpdateImage.OpType.INSERT,false);
        db.add(dbi);
        TransactionState.PerSourceTransactionalUpdate dbUpdate = new TransactionState.PerSourceTransactionalUpdate(
                                                                                                                   sourceId, db);
        dbUpdates.add(dbUpdate);
View Full Code Here

            1);
        keyPairs.add(kp);
        GenericRecord gr = new GenericData.Record(s);
        gr.put(keyName, k);

        DBUpdateImage dbi = new DBUpdateImage(keyPairs, scn, gr, s,
                                              DbUpdateState.DBUpdateImage.OpType.INSERT,false);
        db.add(dbi);
        TransactionState.PerSourceTransactionalUpdate dbUpdate = new TransactionState.PerSourceTransactionalUpdate(
                                                                                                                   sourceId, db);
        dbUpdates.add(dbUpdate);
View Full Code Here

    GenericRecord gr5 = new GenericData.Record(s);
    gr5.put("name1", "phani5");
    gr5.put("name2", "boris5");


    DBUpdateImage dbi1 = new DBUpdateImage(keyPairs, scn, gr1, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT, false);
    DBUpdateImage dbi2 = new DBUpdateImage(keyPairs, scn, gr2, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT, false);
    DBUpdateImage dbi3 = new DBUpdateImage(keyPairs, scn, gr3, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT, false);
    DBUpdateImage dbi4 = new DBUpdateImage(keyPairs, scn, gr4, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT, false);
    DBUpdateImage dbi5 = new DBUpdateImage(keyPairs, scn, gr5, s,
        DbUpdateState.DBUpdateImage.OpType.INSERT, false);

    db.add(dbi1);
    db.add(dbi2);
    db.add(dbi3);
View Full Code Here

    // Create the event producer
    String uri = pConfig.getUri();
    if(uri == null)
      throw new DatabusException("Uri is required to start the relay");
    uri = uri.trim();
    EventProducer producer = null;
    if (uri.startsWith("jdbc:")) {
      SourceType sourceType = pConfig.getReplBitSetter().getSourceType();
          if (SourceType.TOKEN.equals(sourceType))
            throw new DatabusException("Token Source-type for Replication bit setter config cannot be set for trigger-based Databus relay !!");
View Full Code Here

    LOG.info("Starting. Producers are :" + _producers);

    for (Entry<PhysicalPartition, EventProducer> entry : _producers
        .entrySet()) {
      EventProducer producer = entry.getValue();
      // now start the default DB puller thread; depending on
      // configuration setting / cmd line
      if (this.getDbPullerStart()) {
        if (producer != null) {
          LOG.info("starting db puller: " + producer.getName());
          producer.start(-1L);
          LOG.info("db puller started: " + producer.getName());
        }
      }
    }
  }
View Full Code Here

  @Override
  public void pause() {
    for (Entry<PhysicalPartition, EventProducer> entry : _producers
        .entrySet()) {
      EventProducer producer = entry.getValue();

      if (null != producer) {
        if (producer.isRunning()) {
          producer.pause();
          LOG.info("EventProducer :" + producer.getName()
              + "  pause sent");
        } else if (producer.isPaused()) {
          LOG.info("EventProducer :" + producer.getName()
              + "  already paused");
        }
      }
    }
  }
View Full Code Here

  @Override
  public void resume() {
    for (Entry<PhysicalPartition, EventProducer> entry : _producers
        .entrySet()) {
      EventProducer producer = entry.getValue();
      if (null != producer) {
        if (producer.isPaused()) {
          producer.unpause();
          LOG.info("EventProducer :" + producer.getName()
              + "  resume sent");
        } else if (producer.isRunning()) {
          LOG.info("EventProducer :" + producer.getName()
              + "  already running");
        }
      }
    }
  }
View Full Code Here

  protected void doShutdown() {
    LOG.warn("Shutting down Relay!");
    for (Entry<PhysicalPartition, EventProducer> entry : _producers
        .entrySet()) {
      PhysicalPartition pPartition = entry.getKey();
      EventProducer producer = entry.getValue();

      if (null != producer
          && (producer.isRunning() || producer.isPaused())) {
        producer.shutdown();
        try {
          producer.waitForShutdown();
        } catch (InterruptedException ie) {
        }
        LOG.info("EventProducer is shutdown!");
      }
View Full Code Here

TOP

Related Classes of com.linkedin.databus2.relay.GoldenGateEventProducer

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.