<commit_before>package com.netflix.priam.aws;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.simpledb.model.Item;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.model.Attribute;
import com.amazonaws.services.simpledb.model.DeleteAttributesRequest;
import com.amazonaws.services.simpledb.model.PutAttributesRequest;
import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
import com.amazonaws.services.simpledb.model.SelectRequest;
import com.amazonaws.services.simpledb.model.SelectResult;
import com.amazonaws.services.simpledb.model.UpdateCondition;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.netflix.priam.ICredential;
import com.netflix.priam.identity.PriamInstance;

/**
 * DAO for handling Instance identity information such as token, zone, region
 */
@Singleton
public class SDBInstanceData
{
    public static class Attributes
    {
        public final static String APP_ID = "appId";
        public final static String ID = "id";
        public final static String INSTANCE_ID = "instanceId";
        public final static String TOKEN = "token";
        public final static String AVAILABILITY_ZONE = "availabilityZone";
        public final static String ELASTIC_IP = "elasticIP";
        public final static String UPDATE_TS = "updateTimestamp";
        public final static String LOCATION = "location";
        public final static String HOSTNAME = "hostname";
    }
    public static final String DOMAIN = "InstanceIdentity";
    public static String ALL_QUERY = "select * from " + DOMAIN + " where " + Attributes.APP_ID + "='%s'";
    public static String INSTANCE_QUERY = "select * from " + DOMAIN + " where " + Attributes.APP_ID + "='%s' and " + Attributes.INSTANCE_ID + "='%d'";

    private final ICredential provider;
    
    @Inject
    public SDBInstanceData(ICredential provider)
    {
        this.provider = provider;       
    }

    /**
     * Get the instance details from SimpleDB
     * 
     * @param app
     *            Cluster name
     * @param id
     *            Node ID
     * @return
     */
    public PriamInstance getInstance(String app, int id)
    {
        AmazonSimpleDBClient simpleDBClient = getSimpleDBClient();
        SelectRequest request = new SelectRequest(String.format(INSTANCE_QUERY, app, id));
        SelectResult result = simpleDBClient.select(request);<commit_msg>Fix instance id query for SDB<commit_after>package com.netflix.priam.aws;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.simpledb.model.Item;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.model.Attribute;
import com.amazonaws.services.simpledb.model.DeleteAttributesRequest;
import com.amazonaws.services.simpledb.model.PutAttributesRequest;
import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
import com.amazonaws.services.simpledb.model.SelectRequest;
import com.amazonaws.services.simpledb.model.SelectResult;
import com.amazonaws.services.simpledb.model.UpdateCondition;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.netflix.priam.ICredential;
import com.netflix.priam.identity.PriamInstance;

/**
 * DAO for handling Instance identity information such as token, zone, region
 */
@Singleton
public class SDBInstanceData
{
    public static class Attributes
    {
        public final static String APP_ID = "appId";
        public final static String ID = "id";
        public final static String INSTANCE_ID = "instanceId";
        public final static String TOKEN = "token";
        public final static String AVAILABILITY_ZONE = "availabilityZone";
        public final static String ELASTIC_IP = "elasticIP";
        public final static String UPDATE_TS = "updateTimestamp";
        public final static String LOCATION = "location";
        public final static String HOSTNAME = "hostname";
    }
    public static final String DOMAIN = "InstanceIdentity";
    public static String ALL_QUERY = "select * from " + DOMAIN + " where " + Attributes.APP_ID + "='%s'";
    public static String INSTANCE_QUERY = "select * from " + DOMAIN + " where " + Attributes.APP_ID + "='%s' and " + Attributes.ID + "='%d'";

    private final ICredential provider;
    
    @Inject
    public SDBInstanceData(ICredential provider)
    {
        this.provider = provider;       
    }

    /**
     * Get the instance details from SimpleDB
     * 
     * @param app
     *            Cluster name
     * @param id
     *            Node ID
     * @return
     */
    public PriamInstance getInstance(String app, int id)
    {
        AmazonSimpleDBClient simpleDBClient = getSimpleDBClient();
        SelectRequest request = new SelectRequest(String.format(INSTANCE_QUERY, app, id));
        SelectResult result = simpleDBClient.select(request);
{'fraction_non_alphanumeric': 0.0921572315215347, 'fraction_numerical': 0.0, 'mean_word_length': 3.6404886561954624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611103', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1507, 'n_words': 382}