Druid with Java

Hi,
Can anyone help to load the data from JSON file to DRUID database?
I am facing while loading the JSON file to DRUID database server.
The following code i am using to load the data but only nodes are sending to the database server.
How i can set the dimensions value on the following code.
The JSON file is:
{
“type” : “index_hadoop”,
“spec” : {
“ioConfig” : {
“type” : “hadoop”,
“inputSpec” : {
“type” : “static”
}
},
“dataSchema” : {
“dataSource” : “AAAAAAA”,
“granularitySpec” : {
“type” : “uniform”,
“segmentGranularity” : “day”,
“queryGranularity” : “none”,
“intervals” : [“2015-09-12/2015-09-13”]
},
“parser” : {
“type” : “string”,
“parseSpec” : {
“format” : “json”,
“dimensionsSpec” : {
“dimensions” : [
“cityName”,
“user”
]
},
“timestampSpec” : {
“format” : “auto”,
“column” : “time”
}
}
},
“metricsSpec” : [
{
“name” : “added”,
“type” : “longSum”,
“fieldName” : “added”
}
]
},
“tuningConfig” : {
“type” : “hadoop”,
“partitionsSpec” : {
“type” : “hashed”,
“targetPartitionSize” : 5000000
},
“jobProperties” : {}
}
}
}
The Java code is:
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
public class HttpClientTest2 {
public static String postJSon(String url, String content)
throws IOException {
System.out.println("URL: " + url + " and JSON: " + content);
HttpPost httpPost = new HttpPost(url);
StringEntity jsonInput = new StringEntity(content);
jsonInput.setContentType(“application/json”);
httpPost.setEntity(jsonInput);
return HttpClients.createDefault().execute(httpPost).toString();
}
public static void main(String args) {
String url = “http://192.168.XXX.XXX:XXXX/druid/indexer/v1/task”;
String jsonFilePath = “quickstart/wikiticker-index.json”;
String content = “”;
try {
content = new String(Files.readAllBytes(Paths.get(jsonFilePath)));
System.out.println("The response is: " + postJSon(url, content));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Note: XXX means some number.
I want to send the data as below:

[
[
{
“columnType”: “DECIMAL”,
“columnValue”: “24”,
“columnName”: “Id”
},
{
“columnType”: “DECIMAL”,
“columnValue”: “1”,
“columnName”: “locationId”
},
{
“columnType”: “VARCHAR”,
“columnValue”: “CA”,
“columnName”: “locationName”
},
{
“columnType”: “DECIMAL”,
“columnValue”: “5”,
“columnName”: “storeId”
}
],
[
{
“columnType”: “DECIMAL”,
“columnValue”: “21”,
“columnName”: “Id”
},
{
“columnType”: “DECIMAL”,
“columnValue”: “12”,
“columnName”: “locationId”
},
{
“columnType”: “VARCHAR”,
“columnValue”: “USA”,
“columnName”: “locationName”
},
{
“columnType”: “DECIMAL”,
“columnValue”: “33”,
“columnName”: “storeId”
}
]
]
How to send the above data to the DRUID database server?
Please co-operate for the same.

Thanks in advance.

Hello,

There are numerous ways to ingest data into Druid and each way uses a different ingestion spec. This page provides a good overview and contains links you can follow once you’ve determined the most appropriate method: http://druid.io/docs/0.9.2/tutorials/ingestion.html