Package org.apache.sqoop.submission.counter

Examples of org.apache.sqoop.submission.counter.Counter


        if(group == null) {
          group = new CounterGroup(groupName);
          counters.addCounterGroup(group);
        }

        group.addCounter(new Counter(counterName, value));
      }

      if(counters.isEmpty()) {
        return null;
      } else {
View Full Code Here


    }

    for(org.apache.hadoop.mapred.Counters.Group hadoopGroup : hadoopCounters) {
      CounterGroup sqoopGroup = new CounterGroup(hadoopGroup.getName());
      for(org.apache.hadoop.mapred.Counters.Counter hadoopCounter : hadoopGroup) {
        Counter sqoopCounter = new Counter(hadoopCounter.getName(), hadoopCounter.getValue());
        sqoopGroup.addCounter(sqoopCounter);
      }
      sqoopCounters.addCounterGroup(sqoopGroup);
    }
View Full Code Here

      CounterGroup group = new CounterGroup(groupEntry.getKey());

      Set<Map.Entry<String, Long>> counterSet = groupEntry.getValue().entrySet();

      for(Map.Entry<String, Long> counterEntry: counterSet) {
        Counter counter = new Counter(counterEntry.getKey(), counterEntry.getValue());
        group.addCounter(counter);
      }

      counters.addCounterGroup(group);
    }
View Full Code Here

  }

  public void testTransferCounters() {
    Counters counters = new Counters();
    counters.addCounterGroup(new CounterGroup("A")
      .addCounter(new Counter("X", 1))
      .addCounter(new Counter("Y", 2))
    );
    counters.addCounterGroup(new CounterGroup("B")
      .addCounter(new Counter("XX", 11))
      .addCounter(new Counter("YY", 22))
    );

    MSubmission source = new MSubmission();
    source.setCounters(counters);

    Counters target;
    CounterGroup group;
    Counter counter;

    target = transfer(source).getCounters();
    group = target.getCounterGroup("A");
    assertNotNull(group);
    counter = group.getCounter("X");
    assertNotNull(counter);
    assertEquals(1, counter.getValue());
    counter = group.getCounter("Y");
    assertNotNull(counter);
    assertEquals(2, counter.getValue());

    target = transfer(source).getCounters();
    group = target.getCounterGroup("B");
    assertNotNull(group);
    counter = group.getCounter("XX");
    assertNotNull(counter);
    assertEquals(11, counter.getValue());
    counter = group.getCounter("YY");
    assertNotNull(counter);
    assertEquals(22, counter.getValue());

    Counters countersx = new Counters();
    countersx.addCounterGroup(new CounterGroup("C")
      .addCounter(new Counter("XXX", 111))
      .addCounter(new Counter("YYY", 222))
    );
    countersx.addCounterGroup(new CounterGroup("D")
      .addCounter(new Counter("XXXX", 1111))
      .addCounter(new Counter("YYYY", 2222))
    );

    Counters countersy = new Counters();
    countersy.addCounterGroup(new CounterGroup("E")
      .addCounter(new Counter("XXXXX", 11111))
      .addCounter(new Counter("YYYYY", 22222))
    );
    countersy.addCounterGroup(new CounterGroup("F")
      .addCounter(new Counter("XXXXXX", 111111))
      .addCounter(new Counter("YYYYYY", 222222))
    );

    List<MSubmission> sources = new ArrayList<MSubmission>();
    MSubmission sourcex = new MSubmission();
    sourcex.setCounters(countersx);
    sources.add(sourcex);
    MSubmission sourcey = new MSubmission();
    sourcey.setCounters(countersy);
    sources.add(sourcey);

    List<MSubmission> targets = transfer(sources);
    assertNotNull(targets.get(0));
    target = targets.get(0).getCounters();
    group = target.getCounterGroup("C");
    assertNotNull(group);
    counter = group.getCounter("XXX");
    assertNotNull(counter);
    assertEquals(111, counter.getValue());
    counter = group.getCounter("YYY");
    assertNotNull(counter);
    assertEquals(222, counter.getValue());

    group = target.getCounterGroup("D");
    assertNotNull(group);
    counter = group.getCounter("XXXX");
    assertNotNull(counter);
    assertEquals(1111, counter.getValue());
    counter = group.getCounter("YYYY");
    assertNotNull(counter);
    assertEquals(2222, counter.getValue());

    assertNotNull(targets.get(1));
    target = targets.get(1).getCounters();
    group = target.getCounterGroup("E");
    assertNotNull(group);
    counter = group.getCounter("XXXXX");
    assertNotNull(counter);
    assertEquals(11111, counter.getValue());
    counter = group.getCounter("YYYYY");
    assertNotNull(counter);
    assertEquals(22222, counter.getValue());

    group = target.getCounterGroup("F");
    assertNotNull(group);
    counter = group.getCounter("XXXXXX");
    assertNotNull(counter);
    assertEquals(111111, counter.getValue());
    counter = group.getCounter("YYYYYY");
    assertNotNull(counter);
    assertEquals(222222, counter.getValue());
  }
View Full Code Here

        if(group == null) {
          group = new CounterGroup(groupName);
          counters.addCounterGroup(group);
        }

        group.addCounter(new Counter(counterName, value));
      }

      if(counters.isEmpty()) {
        return null;
      } else {
View Full Code Here

  }

  public void testTransferCounters() {
    Counters counters = new Counters();
    counters.addCounterGroup(new CounterGroup("A")
      .addCounter(new Counter("X", 1))
      .addCounter(new Counter("Y", 2))
    );
    counters.addCounterGroup(new CounterGroup("B")
      .addCounter(new Counter("XX", 11))
      .addCounter(new Counter("YY", 22))
    );

    MSubmission source = new MSubmission();
    source.setCounters(counters);

    Counters target;
    CounterGroup group;
    Counter counter;

    target = transfer(source).getCounters();
    group = target.getCounterGroup("A");
    assertNotNull(group);
    counter = group.getCounter("X");
    assertNotNull(counter);
    assertEquals(1, counter.getValue());
    counter = group.getCounter("Y");
    assertNotNull(counter);
    assertEquals(2, counter.getValue());

    target = transfer(source).getCounters();
    group = target.getCounterGroup("B");
    assertNotNull(group);
    counter = group.getCounter("XX");
    assertNotNull(counter);
    assertEquals(11, counter.getValue());
    counter = group.getCounter("YY");
    assertNotNull(counter);
    assertEquals(22, counter.getValue());
  }
View Full Code Here

      CounterGroup group = new CounterGroup(groupEntry.getKey());

      Set<Map.Entry<String, Long>> counterSet = groupEntry.getValue().entrySet();

      for(Map.Entry<String, Long> counterEntry: counterSet) {
        Counter counter = new Counter(counterEntry.getKey(), counterEntry.getValue());
        group.addCounter(counter);
      }

      counters.addCounterGroup(group);
    }
View Full Code Here

  }

  public void testTransferCounters() {
    Counters counters = new Counters();
    counters.addCounterGroup(new CounterGroup("A")
      .addCounter(new Counter("X", 1))
      .addCounter(new Counter("Y", 2))
    );
    counters.addCounterGroup(new CounterGroup("B")
      .addCounter(new Counter("XX", 11))
      .addCounter(new Counter("YY", 22))
    );

    MSubmission source = new MSubmission();
    source.setCounters(counters);

    Counters target;
    CounterGroup group;
    Counter counter;

    target = transfer(source).getCounters();
    group = target.getCounterGroup("A");
    assertNotNull(group);
    counter = group.getCounter("X");
    assertNotNull(counter);
    assertEquals(1, counter.getValue());
    counter = group.getCounter("Y");
    assertNotNull(counter);
    assertEquals(2, counter.getValue());

    target = transfer(source).getCounters();
    group = target.getCounterGroup("B");
    assertNotNull(group);
    counter = group.getCounter("XX");
    assertNotNull(counter);
    assertEquals(11, counter.getValue());
    counter = group.getCounter("YY");
    assertNotNull(counter);
    assertEquals(22, counter.getValue());
  }
View Full Code Here

    Date creationDate = new Date();
    Date updateDate = new Date();

    CounterGroup firstGroup = new CounterGroup("ga");
    CounterGroup secondGroup = new CounterGroup("gb");
    firstGroup.addCounter(new Counter("ca", 100));
    firstGroup.addCounter(new Counter("cb", 200));
    secondGroup.addCounter(new Counter("ca", 300));
    secondGroup.addCounter(new Counter("cd", 400));
    Counters counters = new Counters();
    counters.addCounterGroup(firstGroup);
    counters.addCounterGroup(secondGroup);

    MSubmission submission = new MSubmission();
    submission.setJobId(1);
    submission.setStatus(SubmissionStatus.RUNNING);
    submission.setCreationDate(creationDate);
    submission.setLastUpdateDate(updateDate);
    submission.setExternalId("job-x");
    submission.setExternalLink("http://somewhere");
    submission.setExceptionInfo("RuntimeException");
    submission.setExceptionStackTrace("Yeah it happens");
    submission.setCounters(counters);

    handler.createSubmission(submission, getDerbyConnection());

    assertEquals(1, submission.getPersistenceId());
    assertCountForTable("SQOOP.SQ_SUBMISSION", 1);

    List<MSubmission> submissions =
      handler.findSubmissionsUnfinished(getDerbyConnection());
    assertNotNull(submissions);
    assertEquals(1, submissions.size());

    submission = submissions.get(0);

    assertEquals(1, submission.getJobId());
    assertEquals(SubmissionStatus.RUNNING, submission.getStatus());
    assertEquals(creationDate, submission.getCreationDate());
    assertEquals(updateDate, submission.getLastUpdateDate());
    assertEquals("job-x", submission.getExternalId());
    assertEquals("http://somewhere", submission.getExternalLink());
    assertEquals("RuntimeException", submission.getExceptionInfo());
    assertEquals("Yeah it happens", submission.getExceptionStackTrace());

    CounterGroup group;
    Counter counter;
    Counters retrievedCounters = submission.getCounters();
    assertNotNull(retrievedCounters);

    group = counters.getCounterGroup("ga");
    assertNotNull(group);

    counter = group.getCounter("ca");
    assertNotNull(counter);
    assertEquals(100, counter.getValue());

    counter = group.getCounter("cb");
    assertNotNull(counter);
    assertEquals(200, counter.getValue());

    group = counters.getCounterGroup("gb");
    assertNotNull(group);

    counter = group.getCounter("ca");
    assertNotNull(counter);
    assertEquals(300, counter.getValue());

    counter = group.getCounter("cd");
    assertNotNull(counter);
    assertEquals(400, counter.getValue());

    // Let's create second (simpler) connection
    submission =
      new MSubmission(1, new Date(), SubmissionStatus.SUCCEEDED, "job-x");
    handler.createSubmission(submission, getDerbyConnection());
View Full Code Here

      CounterGroup group = new CounterGroup(groupEntry.getKey());

      Set<Map.Entry<String, Long>> counterSet = groupEntry.getValue().entrySet();

      for(Map.Entry<String, Long> counterEntry: counterSet) {
        Counter counter = new Counter(counterEntry.getKey(), counterEntry.getValue());
        group.addCounter(counter);
      }

      counters.addCounterGroup(group);
    }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.submission.counter.Counter

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.