Querying WADPerformanceCountersTable using Java microsoft-windowsazure-api.jar

Hi,

How to query WADPerformanceCountersTable using Java microsoft-windowsazure-api.

Need to fileter the result based on PartitionKey.

eg.

TableQuery <DynamicTableEntity> SQL = TableQuery.from(Constants.

"PartitionKey ge '0" + startPartitionKey + "'").where(

"PartitionKey le '0" + endPartitionKey + "'").where(

"DeploymentId eq '" + deploymentId + "'").where(

"RoleInstance eq '" + roleInstance + "'").select(new String[]{"CounterName","DeploymentId","CounterValue", "RoleInstance"});

Its giving following exception:

java.util.NoSuchElementException: An error occurred while enumerating the result, check the original exception for details.
20140108163015 Response:         at com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:113)
20140108163015 Response:         at com.bmc.collector.azure.Performance.getAzureDiagnosticData(Performance.java:311)
20140108163015 Response:         at com.bmc.collector.azure.Performance.run(Performance.java:70)
20140108163015 Response:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
20140108163015 Response:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
20140108163015 Response:         at java.lang.Thread.run(Thread.java:722)
20140108163015 Response: Caused by: com.microsoft.windowsazure.services.table.client.TableServiceException: Bad Request
20140108163015 Response:         at com.microsoft.windowsazure.services.table.client.TableServiceException.generateTableServiceException(TableServiceException.java:57)
20140108163015 Response:         at com.microsoft.windowsazure.services.table.client.CloudTableClient.executeQuerySegmentedCore(CloudTableClient.java:807)
20140108163015 Response:         at com.microsoft.windowsazure.services.table.client.CloudTableClient$3.execute(CloudTableClient.java:951)
20140108163015 Response:         at com.microsoft.windowsazure.services.table.client.CloudTableClient$3.execute(CloudTableClient.java:945)
20140108163015 Response:         at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.java:114)
20140108163015 Response:         at com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:109)

PERFORMANCE_COUNTER_TABLE, DynamicTableEntity.class).where(
January 8th, 2014 2:09pm

hi,

Base on my experience, I think it is the best that we use "TableQuery.generateFilterCondition" to create the fliter condition instead of strings. Like this (http://www.windowsazure.com/en-us/develop/java/how-to-guides/table-service/ ):

String partitionFilter = TableQuery.generateFilterCondition(
    TableConstants.PARTITION_KEY, 
    QueryComparisons.EQUAL,
    "Smith");

// Specify a partition query, using "Smith" as the partition key filter.
TableQuery<CustomerEntity> partitionQuery =
    TableQuery.from("people", CustomerEntity.class)
    .where(partitionFilter);

By the way, I suggest you could use less filter condition to test. If it shown result right, you could add other condition on query sentence.

Please try it.

Regards,

Will

Free Windows Admin Tool Kit Click here and download it now
January 9th, 2014 7:49am

Thanks Will for your help!

I tried following:

String pkFilterge = TableQuery.generateFilterCondition(TableConstants.PARTITION_KEY, QueryComparisons.GREATER_THAN_OR_EQUAL,"0" + startPartitionKey);

TableQuery<PerformanceData> SQL = TableQuery.from(Constants.PERFORMANCE_COUNTER_TABLE, PerformanceData.class).where(pkFilterge);

And also

String depidFilter = TableQuery.generateFilterCondition("DeploymentId", TableQuery.QueryComparisons.EQUAL,  deploymentId);

TableQuery<PerformanceData> SQL = TableQuery.from(Constants.PERFORMANCE_COUNTER_TABLE, PerformanceData.class).where(pkFilterge);

But it gives similar exception:

java.util.NoSuchElementException: An error occurred while enumerating the result, check the original exception for details.

       at com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:113)

Caused by: com.microsoft.windowsazure.services.table.client.TableServiceException: Bad Request

       at com.microsoft.windowsazure.services.table.client.TableServiceException.generateTableServiceException(TableServiceException.java:57)

Thanks,

Prit

January 9th, 2014 9:32am

Hi,

The error was because of some additional filter on which I need to work.

Its working now.

Thanks Will for your help!

Free Windows Admin Tool Kit Click here and download it now
January 9th, 2014 11:08am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics