Package org.apache.ivory.entity.v0.feed

Examples of org.apache.ivory.entity.v0.feed.Feed


  @Override
  public void cleanup() throws IvoryException {
    Collection<String> feeds = STORE.getEntities(EntityType.FEED);
    for (String feedName : feeds) {
      Feed feed;
      feed = STORE.get(EntityType.FEED, feedName);
      long retention = getRetention(feed, feed.getFrequency()
          .getTimeUnit());
      for (org.apache.ivory.entity.v0.feed.Cluster cluster : feed
          .getClusters().getClusters()) {
        Cluster currentCluster = STORE.get(EntityType.CLUSTER,
            cluster.getName());
        if(currentCluster.getColo().equals(getCurrentColo())){
          LOG.info("Cleaning up logs for process:" + feedName
View Full Code Here


public class TestWorkflowNameBuilder {

  @Test
  public void getTagTest() {
    Feed feed = new Feed();
    feed.setName("raw-logs");

    WorkflowNameBuilder<Feed> builder = new WorkflowNameBuilder<Feed>(feed);
    Tag tag = builder.getWorkflowTag("IVORY_FEED_RETENTION_raw-logs");
    Assert.assertEquals(tag, Tag.RETENTION);
View Full Code Here

  }

  @Test
  public void getSuffixesTest() {
    Feed feed = new Feed();
    feed.setName("raw-logs");
    WorkflowNameBuilder<Feed> builder = new WorkflowNameBuilder<Feed>(feed);

    String suffixes = builder
        .getWorkflowSuffixes("IVORY_FEED_REPLICATION_raw-logs_corp-1");
    Assert.assertEquals(suffixes, "_corp-1");
View Full Code Here

    Assert.assertEquals(suffixes, "");
  }

  @Test
  public void WorkflowNameTest() {
    Feed feed = new Feed();
    feed.setName("raw-logs");

    WorkflowNameBuilder<Feed> builder = new WorkflowNameBuilder<Feed>(feed);
    Assert.assertEquals(builder.getWorkflowName().toString(),
        "IVORY_FEED_raw-logs");
View Full Code Here

  }

  @Test
  public void testParse() throws IOException, IvoryException, JAXBException {

    Feed feed = parser.parseAndValidate(this.getClass()
        .getResourceAsStream(FEED_XML));

    Assert.assertNotNull(feed);
    assertEquals(feed.getName(), "clicks");
    assertEquals(feed.getDescription(), "clicks log");
    assertEquals(feed.getFrequency().toString(), "hours(1)");
    assertEquals(feed.getGroups(), "online,bi");

    assertEquals(feed.getClusters().getClusters().get(0).getName(),
        "testCluster");
    assertEquals(feed.getClusters().getClusters().get(0).getType(),
        ClusterType.SOURCE);
    assertEquals(SchemaHelper.formatDateUTC(feed.getClusters().getClusters().get(0).getValidity()
        .getStart()), "2011-11-01T00:00Z");
    assertEquals(SchemaHelper.formatDateUTC(feed.getClusters().getClusters().get(0).getValidity()
        .getEnd()), "2011-12-31T00:00Z");
    assertEquals(feed.getTimezone().getID(), "UTC");
    assertEquals(feed.getClusters().getClusters().get(0).getRetention()
        .getAction(), ActionType.DELETE);
    assertEquals(feed.getClusters().getClusters().get(0).getRetention()
        .getLimit().toString(), "hours(48)");

    assertEquals(feed.getClusters().getClusters().get(1).getName(),
        "backupCluster");
    assertEquals(feed.getClusters().getClusters().get(1).getType(),
        ClusterType.TARGET);
    assertEquals(SchemaHelper.formatDateUTC(feed.getClusters().getClusters().get(1).getValidity()
        .getStart()), "2011-11-01T00:00Z");
    assertEquals(SchemaHelper.formatDateUTC(feed.getClusters().getClusters().get(1).getValidity()
        .getEnd()), "2011-12-31T00:00Z");
    assertEquals(feed.getClusters().getClusters().get(1).getRetention()
        .getAction(), ActionType.ARCHIVE);
    assertEquals(feed.getClusters().getClusters().get(1).getRetention()
        .getLimit().toString(), "hours(6)");

    assertEquals(FeedHelper.getLocation(feed, LocationType.DATA).getPath(),
        "/projects/ivory/clicks");
    assertEquals(FeedHelper.getLocation(feed, LocationType.META).getPath(),
        "/projects/ivory/clicksMetaData");
    assertEquals(FeedHelper.getLocation(feed, LocationType.STATS).getPath(),
        "/projects/ivory/clicksStats");

    assertEquals(feed.getACL().getGroup(), "group");
    assertEquals(feed.getACL().getOwner(), "testuser");
    assertEquals(feed.getACL().getPermission(), "0x755");

    assertEquals(feed.getSchema().getLocation(), "/schema/clicks");
    assertEquals(feed.getSchema().getProvider(), "protobuf");

    StringWriter stringWriter = new StringWriter();
    Marshaller marshaller = EntityType.FEED.getMarshaller();
    marshaller.marshal(feed, stringWriter);
    System.out.println(stringWriter.toString());
View Full Code Here

    System.out.println(stringWriter.toString());
  }

  @Test(expectedExceptions = ValidationException.class)
  public void applyValidationInvalidFeed() throws Exception {
    Feed feed = (Feed) parser
        .parseAndValidate(ProcessEntityParserTest.class
            .getResourceAsStream(FEED_XML));
    feed.getClusters().getClusters().get(0).setName("invalid cluster");
    parser.validate(feed);
  }
View Full Code Here

  }

 
  @Test
  public void testPartitionExpression() throws IvoryException {
        Feed feed = (Feed) parser.parseAndValidate(ProcessEntityParserTest.class
                .getResourceAsStream(FEED_XML));
       
        //When there are more than 1 src clusters, there should be partition expression
        org.apache.ivory.entity.v0.feed.Cluster newCluster = new org.apache.ivory.entity.v0.feed.Cluster();
        newCluster.setName("newCluster");
        newCluster.setType(ClusterType.SOURCE);
        newCluster.setPartition("${cluster.colo}");
        feed.getClusters().getClusters().add(newCluster);
        try {
            parser.validate(feed);
            Assert.fail("Expected ValidationException");
        } catch(ValidationException e) { }
       
        //When there are more than 1 src clusters, the partition expression should contain cluster variable
        feed.getClusters().getClusters().get(0).setPartition("*");
        try {
            parser.validate(feed);
            Assert.fail("Expected ValidationException");
        } catch(ValidationException e) { }
       
        //When there are more than 1 target cluster, there should be partition expre
        newCluster.setType(ClusterType.TARGET);
        try {
            parser.validate(feed);
            Assert.fail("Expected ValidationException");
        } catch(ValidationException e) { }
       
        //When there are more than 1 target clusters, the partition expression should contain cluster variable
        feed.getClusters().getClusters().get(1).setPartition("*");
        try {
            parser.validate(feed);
            Assert.fail("Expected ValidationException");
        } catch(ValidationException e) { }
       
        //Number of parts in partition expression < number of partitions defined for feed
        feed.getClusters().getClusters().get(1).setPartition("*/*");
        try {
            parser.validate(feed);
            Assert.fail("Expected ValidationException");
        } catch(ValidationException e) { }

        feed.getClusters().getClusters().get(0).setPartition(null);
        feed.getClusters().getClusters().get(1).setPartition(null);
        feed.getClusters().getClusters().remove(2);
        feed.setPartitions(null);
        parser.validate(feed);
  }
View Full Code Here

    }
  }

  @Test(expectedExceptions = ValidationException.class)
  public void testInvalidProcessValidity() throws Exception {
    Feed feed = parser.parseAndValidate((FeedEntityParserTest.class
        .getResourceAsStream(FEED_XML)));
    feed.getClusters().getClusters().get(0).getValidity()
        .setStart(SchemaHelper.parseDateUTC("2012-11-01T00:00Z"));
    parser.validate(feed);
  }
View Full Code Here

    parser.validate(feed);
  }

  @Test
  public void testValidFeedGroup() throws IvoryException, JAXBException {
    Feed feed1 = (Feed) EntityType.FEED.getUnmarshaller().unmarshal(
        (FeedEntityParserTest.class.getResourceAsStream(FEED_XML)));
    feed1.setName("f1" + System.currentTimeMillis());
    feed1.setGroups("group1,group2,group3");
    feed1.setLocations(new Locations());
    Location location = new Location();
    location.setPath("/projects/bi/rmc/daily/ad/${YEAR}/fraud/${MONTH}-${DAY}/ad");
    location.setType(LocationType.DATA);
    feed1.getLocations().getLocations().add(location);
    feed1.getClusters().getClusters().get(0).getLocations().getLocations().set(0, location);
    parser.parseAndValidate(feed1.toString());
    ConfigurationStore.get().publish(EntityType.FEED, feed1);

    Feed feed2 = (Feed) EntityType.FEED.getUnmarshaller().unmarshal(
        (FeedEntityParserTest.class.getResourceAsStream(FEED_XML)));
    feed2.setName("f2" + System.currentTimeMillis());
    feed2.setGroups("group1,group2,group5");
    feed2.setLocations(new Locations());
    Location location2 = new Location();
    location2
        .setPath("/projects/bi/rmc/daily/ad/${YEAR}/fraud/${MONTH}-${DAY}/ad");
    location2.setType(LocationType.DATA);
    feed2.getLocations().getLocations().add(location2);
    feed2.getClusters().getClusters().get(0).getLocations().getLocations().set(0, location);
    parser.parseAndValidate(feed2.toString());
  }
View Full Code Here

        }
        return propertiesMap;
    }

    private void addOptionalInputProperties(Properties properties, Input in, String clusterName) throws IvoryException {
        Feed feed = EntityUtil.getEntity(EntityType.FEED, in.getFeed());
        org.apache.ivory.entity.v0.feed.Cluster cluster = FeedHelper.getCluster(feed, clusterName);
        String inName = in.getName();
        properties.put(inName + ".frequency", String.valueOf(feed.getFrequency().getFrequency()));
        properties.put(inName + ".freq_timeunit", mapToCoordTimeUnit(feed.getFrequency().getTimeUnit()).name());
        properties.put(inName + ".timezone", feed.getTimezone().getID());
        properties.put(inName + ".end_of_duration", Timeunit.NONE.name());
        properties.put(inName + ".initial-instance", SchemaHelper.formatDateUTC(cluster.getValidity().getStart()));
        properties.put(inName + ".done-flag", "notused");
       
        String locPath = FeedHelper.getLocation(feed, LocationType.DATA, clusterName).getPath().replace('$', '%');
View Full Code Here

TOP

Related Classes of org.apache.ivory.entity.v0.feed.Feed

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.