Package com.amazonaws.services.simpledb.model

Examples of com.amazonaws.services.simpledb.model.Item


  public int getNumberOfTriggers(SchedulingContext ctxt) {
    log.debug("Finding number of triggers");
    try {
      SelectResult result = amazonSimpleDb.select(new SelectRequest(query
          .countTriggers()));
      Item item = result.getItems().get(0);
      return Integer.parseInt(item.getAttributes().get(0).getValue());
    } catch (Exception e) {
      log.error("Could not find number of triggers", e);
      return -1;
    }
  }
View Full Code Here


    private <T> T findInDb(Class<T> tClass, Object id) throws AmazonClientException {
        String domainName = getDomainName(tClass);
        if (domainName == null)
            return null;
        Item iraw = DomainHelper.findItemById(factory.getSimpleDb(), domainName, id.toString(), consistentRead);
// logger.fine("got back item=" + item);
        if (iraw == null)
            return null;
        SdbItem item = new SdbItemImpl2(iraw);
        return getItemAttributesBuildAndCache(tClass, id, item);
View Full Code Here

        Assert.assertEquals(map.remove("field2"), "value2");
        Assert.assertEquals(map.size(), 0);
    }

    private SelectResult mkSelectResult(String id) {
        Item item = new Item();
        List<Attribute> attrs = new LinkedList<Attribute>();
        attrs.add(new Attribute("id", id));
        attrs.add(new Attribute("eventTime", "1330538400000"));
        attrs.add(new Attribute("region", "region"));
        attrs.add(new Attribute("recordType", "MonkeyEvent"));
        attrs.add(new Attribute("monkeyType", "MONKEY|com.netflix.simianarmy.aws.TestSimpleDBRecorder$Type"));
        attrs.add(new Attribute("eventType", "EVENT|com.netflix.simianarmy.aws.TestSimpleDBRecorder$EventTypes"));
        attrs.add(new Attribute("field1", "value1"));
        attrs.add(new Attribute("field2", "value2"));
        item.setAttributes(attrs);
        item.setName("MONKEY-" + id + "-region");
        SelectResult result = new SelectResult();
        result.setItems(Arrays.asList(item));
        return result;
    }
View Full Code Here

    private <T> T findInDb(Class<T> tClass, Object id) throws AmazonClientException {
        String domainName = getDomainName(tClass);
        if (domainName == null)
            return null;
        Item iraw = DomainHelper.findItemById(factory.getSimpleDb(), domainName, id.toString(), consistentRead);
// logger.fine("got back item=" + item);
        if (iraw == null)
            return null;
        SdbItem item = new SdbItemImpl2(iraw);
        return getItemAttributesBuildAndCache(tClass, id, item);
View Full Code Here

    }

    private SelectResult mkSelectResult(String id, AWSResourceType resourceType, Resource.CleanupState state,
            String description, String ownerEmail, String region, String terminationReason,
            Date expectedTerminationTime, Date markTime, boolean optOut, String fieldName, String fieldValue) {
        Item item = new Item();
        List<Attribute> attrs = new LinkedList<Attribute>();
        attrs.add(new Attribute(AWSResource.FIELD_RESOURCE_ID, id));
        attrs.add(new Attribute(AWSResource.FIELD_RESOURCE_TYPE, resourceType.name()));
        attrs.add(new Attribute(AWSResource.FIELD_DESCRIPTION, description));
        attrs.add(new Attribute(AWSResource.FIELD_REGION, region));
        attrs.add(new Attribute(AWSResource.FIELD_STATE, state.name()));
        attrs.add(new Attribute(AWSResource.FIELD_OWNER_EMAIL, ownerEmail));
        attrs.add(new Attribute(AWSResource.FIELD_TERMINATION_REASON, terminationReason));
        attrs.add(new Attribute(AWSResource.FIELD_EXPECTED_TERMINATION_TIME,
                AWSResource.DATE_FORMATTER.print(expectedTerminationTime.getTime())));
        attrs.add(new Attribute(AWSResource.FIELD_MARK_TIME,
                AWSResource.DATE_FORMATTER.print(markTime.getTime())));
        attrs.add(new Attribute(AWSResource.FIELD_OPT_OUT_OF_JANITOR, String.valueOf(optOut)));
        attrs.add(new Attribute(fieldName, fieldValue));

        item.setAttributes(attrs);
        item.setName(String.format("%s-%s-%s", resourceType.name(), id, region));
        SelectResult result = new SelectResult();
        result.setItems(Arrays.asList(item));
        return result;
    }
View Full Code Here

  public int getNumberOfTriggers(SchedulingContext ctxt) {
    logDebug("Finding number of triggers");
    try {
      SelectResult result = amazonSimpleDb.select(new SelectRequest(query
          .countTriggers()));
      Item item = result.getItems().get(0);
      return Integer.parseInt(item.getAttributes().get(0).getValue());
    } catch (Exception e) {
      log.error("Could not find number of triggers", e);
      return -1;
    }
  }
View Full Code Here

       
        if(results.getAttributes().size() == 0) {
            return null;
        }
       
        Item item = new Item(itemName, results.getAttributes());
        return item;       
   
View Full Code Here

    private <T> T findInDb(Class<T> tClass, Object id) throws AmazonClientException {
        String domainName = getDomainName(tClass);
        if (domainName == null)
            return null;
        Item iraw = DomainHelper.findItemById(factory.getSimpleDb(), domainName, id.toString(), consistentRead);
// logger.fine("got back item=" + item);
        if (iraw == null)
            return null;
        SdbItem item = new SdbItemImpl2(iraw);
        return getItemAttributesBuildAndCache(tClass, id, item);
View Full Code Here

    public int getInt(int index) throws SQLException {
      log.info("getInt(int index) called with index " + index);
        checkPosition();

        Item item = items.get(currentPos);
        List<Attribute> attributes = item.getAttributes();
        Attribute attribute = attributes.get((index - 1));
        return SimpleDBUtils.decodeZeroPaddingInt(getAttributeValue(attribute));
    }
View Full Code Here

    public int getInt(String label) throws SQLException {
      log.info("getInt(String label) called with label " + label);
      checkPosition();

        Item item = items.get(currentPos);
        List<Attribute> attributes = item.getAttributes();
        for (Attribute attribute : attributes) {
            if (getAttributeName(attribute).equals(label)) {
                return SimpleDBUtils.decodeZeroPaddingInt(getAttributeValue(attribute));
            }
        }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.simpledb.model.Item

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.