本文整理汇总了Java中com.amazonaws.services.simpledb.AmazonSimpleDBClient类的典型用法代码示例。如果您正苦于以下问题:Java AmazonSimpleDBClient类的具体用法?Java AmazonSimpleDBClient怎么用?Java AmazonSimpleDBClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AmazonSimpleDBClient类属于com.amazonaws.services.simpledb包,在下文中一共展示了AmazonSimpleDBClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
String customerID = request.getParameter("customerID");
BasicAWSCredentials awsCredentials = new BasicAWSCredentials("test", "test");
AmazonSimpleDBClient sdbc = new AmazonSimpleDBClient(awsCredentials);
String query = "select * from invoices where customerID = '"
+ customerID;
SelectResult sdbResult = sdbc.select(new SelectRequest(query)); //BAD
SelectResult sdbResult2 = sdbc.select(new SelectRequest(query, false)); //BAD
SelectRequest sdbRequest = new SelectRequest();
SelectResult sdbResult3 = sdbc.select(sdbRequest.withSelectExpression(query)); //BAD
String query2 = "select * from invoices where customerID = 123";
SelectResult sdbResult4 = sdbc.select(new SelectRequest(query2)); //OK
}catch(Exception e){
System.out.println(e);
}
}
示例2: configure
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
@Override
public void configure(String name, Properties props, NameSpace ns)
throws LDAPException {
this.name = name;
this.accessKey = props.getProperty("accessKey");
this.secretKey = props.getProperty("secretKey");
this.userDomain = props.getProperty("userDomain");
this.groupDomain = props.getProperty("groupDomain");
this.userDN = new DN("ou=users," + ns.getBase().getDN().toString());
this.groupDN = new DN("ou=groups," + ns.getBase().getDN().toString());
this.baseDN = new DN(ns.getBase().getDN().toString());
this.sdb = new AmazonSimpleDBClient(new BasicAWSCredentials(accessKey,secretKey));
}
示例3: AmazonStatHandler
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public AmazonStatHandler(AmazonSimpleDBClient client, String domain) {
this.client = client;
this.domain = domain;
int tries = 0;
do {
tries++;
try {
ListDomainsResult domainsL = client.listDomains();
if (!domainsL.getDomainNames().contains(domain)) {
client.createDomain(new CreateDomainRequest(domain));
}
return;
} catch (Exception ase) {
log.warn(ase);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
} log.warn(ase);
}
} while (tries < MAX_TRIES);
throw new RuntimeException("Unable to connect to SDB " + domain);
}
示例4: init
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
/**
* The only information needed to create a client are security credentials
* consisting of the AWS Access Key ID and Secret Access Key. All other
* configuration, such as the service endpoints, are performed
* automatically. Client parameters, such as proxies, can be specified in an
* optional ClientConfiguration object when constructing a client.
*
* @see com.amazonaws.auth.BasicAWSCredentials
* @see com.amazonaws.auth.PropertiesCredentials
* @see com.amazonaws.ClientConfiguration
*/
private static void init() throws Exception {
/*
* This credentials provider implementation loads your AWS credentials
* from a properties file at the root of your classpath.
*/
//AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();
BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials("accessKey","secretKey");
AWSCredentialsProvider credentialsProvider = new CredentialsProvider();
ec2 = new AmazonEC2Client(credentialsProvider);
s3 = new AmazonS3Client(credentialsProvider);
sdb = new AmazonSimpleDBClient(credentialsProvider);
}
示例5: getFeedItemNames
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
/**
* Retrieve itemNames for all quotes that were not posted by the user
*
* @param myUserId user ID of the viewer so that their posts do not appear in their main feed
*/
public static List<String> getFeedItemNames(String myUserId) {
SelectRequest selectRequest = new SelectRequest("select itemName() from Quotes where userId != '" + myUserId +
"' and timestamp is not null order by timestamp desc").withConsistentRead(true);
AmazonSimpleDBClient client = getInstance();
if (client != null) {
List<Item> items = client.select(selectRequest).getItems();
List<String> itemNames = new ArrayList<String>();
for (int i = 0; i < items.size(); i++) {
itemNames.add((items.get(i)).getName());
}
return itemNames;
} else return new ArrayList<String>();
}
示例6: doInBackground
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
protected AmazonSimpleDBClient doInBackground(String... urls) {
if (isNetworkAvailable(getActivity())) {
try {
// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getActivity().getApplicationContext(), // Context
"us-east-1:1caef7b3-7585-4ded-961d-0cc8f4bbc87f", // Identity Pool ID
Regions.US_EAST_1 // Region
);
Map<String, String> logins = new HashMap<String, String>();
logins.put("graph.facebook.com", Session.getActiveSession().getAccessToken());
credentialsProvider.withLogins(logins);
Log.d("SimpleDBClient", "My ID is " + credentialsProvider.getIdentityId());
AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentialsProvider);
return client;
} catch (Exception e) {
this.exception = e;
return null;
}
} else return null;
}
示例7: onPostExecute
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
protected void onPostExecute(AmazonSimpleDBClient client) {
if (isNetworkAvailable(getActivity())) {
MainPage.simpleDBClient = client;
new Thread(new Runnable() {
public void run() {
itemNames = SimpleDB.getFeedItemNames(userId);
adapter = new MySimpleArrayAdapter(getActivity().getApplicationContext(), itemNames);
adAdapter = new AdListAdapter(mActivity, adapter);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
setListAdapter(adAdapter);
}
});
}
}).start();
}
}
示例8: provideRings
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
@Provides @Named(RINGS_PROPERTY)
Set<String> provideRings(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory) {
List<String> rings = Lists.newArrayList();
String nextToken = null;
do {
ListDomainsRequest request = new ListDomainsRequest().withNextToken(nextToken);
ListDomainsResult result = client.listDomains(request);
for (String domain : result.getDomainNames()) {
CassandraDomain cassandraDomain = domainFactory.createFromDomain(domain);
if (cassandraDomain != null) {
rings.add(cassandraDomain.getRing());
}
}
nextToken = result.getNextToken();
} while (nextToken != null);
return ImmutableSet.copyOf(rings);
}
示例9: afterPropertiesSet
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
@Override
public final void afterPropertiesSet() {
final AWSCredentials awsCredentials = new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return accessID;
}
@Override
public String getAWSSecretKey() {
return secretKey;
}
};
this.simpleDbClient = new AmazonSimpleDBClient(awsCredentials);
simpleDbDomain = new SimpleDbDomain(domainPrefix);
}
示例10: before
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
@BeforeClass
public void before() {
AWSCredentials credentials = new BasicAWSCredentials(System.getProperty("AWS_SECRET_KEY_ID"),
System.getProperty("AWS_SECRET_KEY"));
simpeDB = new AmazonSimpleDBClient(credentials, new ClientConfiguration());
simpeDB.setEndpoint(VMRegion.US_WEST_2.getEndpoint());
}
示例11: initialize
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public void initialize(Map<String, String> params) throws WPBIOException {
String accessKey = params.get(CONFIG_ACCESS_KEY);
String secretkey = params.get(CONFIG_SECRET_KEY);
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretkey);
ClientConfiguration clientConfig = new ClientConfiguration();
String protocolStr = params.get(CONFIG_PROTOCOL);
if (protocolStr != null && protocolStr.length()>0)
{
Protocol protocol = Protocol.valueOf(params.get(CONFIG_PROTOCOL));
if (protocol != null)
{
clientConfig.setProtocol(protocol);
}
}
sdbClient = new AmazonSimpleDBClient(awsCredentials, clientConfig);
String endpoint = params.get(CONFIG_ENDPOINT);
if (endpoint != null)
{
sdbClient.setEndpoint(endpoint);
}
domainName = params.get(CONFIG_DOMAIN);
// create the domain if not exists
CreateDomainRequest createDomainRequest = new CreateDomainRequest();
createDomainRequest.setDomainName(domainName);
sdbClient.createDomain(createDomainRequest);
}
示例12: SdbCassandraRingDao
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
@Inject
public SdbCassandraRingDao(AmazonSimpleDBClient client, SdbCassandraInstanceDao instanceDao,
CassandraDomainFactory domainFactory,
@Named(SdbDaoModule.RINGS_PROPERTY) Provider<Set<String>> ringsProvider) {
this.client = client;
this.instanceDao = instanceDao;
this.domainFactory = domainFactory;
this.ringsProvider = ringsProvider;
}
示例13: assertNoStaleDomain
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public static void assertNoStaleDomain(AmazonSimpleDBClient client, String when) {
List<String> staleInstances = client.listDomains().getDomainNames().stream() //
.filter(name -> !name.startsWith(SDBIntegrationTest.class.getSimpleName())
|| System.currentTimeMillis() - AWSUtils.toEpochMillis(name) > AWSUtils.HOUR) //
.collect(Collectors.toList());
Assert.assertEquals(String.format("Found stale SDB domans %s running the test: %s", when, staleInstances), 0,
staleInstances.size());
}
示例14: createDBClient
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public static AmazonSimpleDBClient createDBClient() {
BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
AmazonSimpleDBClient client = !credentials.isValid() ? null : (AmazonSimpleDBClient)
AmazonSimpleDBClientBuilder.standard()
.withCredentials(credentials)
.withRegion("eu-west-1").build();
return client;
}
示例15: createDomain
import com.amazonaws.services.simpledb.AmazonSimpleDBClient; //导入依赖的package包/类
public static void createDomain(AmazonSimpleDBClient client, String domainName) throws InterruptedException {
client.createDomain(new CreateDomainRequest(domainName));
// Unfortunatly, there is no waiters for domain create
int retries = 10;
List<String> domainNames = client.listDomains().getDomainNames();
while (!domainNames.contains(domainName) && 0 < retries--) {
Thread.sleep(500);
domainNames = client.listDomains().getDomainNames();
}
Assert.assertTrue(domainNames.contains(domainName));
}