I have devised the following code to get the info similar to _search_shards rest API in ES:
ClusterSearchShardsRequest clusterSearchShardsRequest
= new ClusterSearchShardsRequest();
clusterSearchShardsRequest.routing("route2");
try {
DiscoveryNode[] discoveryNodes = client().admin().cluster()
.searchShards(clusterSearchShardsRequest)
.get()
.getNodes();
for (int i=0; i<=discoveryNodes.length; i++){
System.out.print("\n\n\n"+discoveryNodes[i].toString()+"\n\n\n");
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
However this tends not to initialize the actual clusterSearchShardsRequest.
How to initialize the clusterSearchShardsRequest for the given client and index?
Simply create the new ClusterSearchShardsRequest(BOOK_INDEX_NAME) with the index name aprameter.
Related
Oops guys! Beauty? I'm trying to get a byte list[] in my Rest template's response, but my exchange isn't accepting the new ParameterizedTypeReference<List<byte[]>>() {} , could someone help me?
ResponseEntity<List<byte[]>> response = null;
try {
response = restTemplate.exchange(parametros.get("SERVICE_HUB2_BASE_URL") + "/fw/v1/pdf/kms/assinaturas",
HttpMethod.POST, entity, new ParameterizedTypeReference<List<byte[]>>() {});
} catch (HttpServerErrorException e) {
e.printStackTrace();
throw new ClientException(e.getStatusCode().value(), e.getStatusText());
} catch (HttpClientErrorException e) {
e.printStackTrace();
throw new ClientException(e.getStatusCode().value(), e.getStatusText());
} catch (Exception e) {
e.printStackTrace();
}
Hi As per the mouse hower it's pointing to different method.
Please check import statement for rest template.
both ways should be fine .
ResponseEntity<Collection<byte[]>> responseEntityOne = restTemplate.exchange(formattedUrl, HttpMethod.POST, entity,
new ParameterizedTypeReference<Collection<byte[]>>(){});
ResponseEntity<List<byte[]>> responseEntityOne1 = restTemplate.exchange(formattedUrl, HttpMethod.POST, entity,
new ParameterizedTypeReference<List<byte[]>>(){});
I want to convert the following into functional program. Please help to stream line the below code.
Map <String, TreeSet<Double>> cusipMap = new HashMap<>();
String[] key = new String[1];
try {
Files.lines(Paths.get("C:\\CUSIP.txt")).
forEach(l -> {
if (isCUSIP(l)) {
if (cusipMap.get(l) == null )
cusipMap.put(l, new TreeSet<Double>());
key[0] = l;
} else {
cusipMap.get(key[0]).add(Double.valueOf(l));
}
});
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Try this one
try {
Map<String, TreeSet<Double>> result = Files.lines(Paths.get("C:\\CUSIP.txt"))
.collect(Collectors.groupingBy(Function.identity(), Collector.of(
TreeSet::new,
(TreeSet<Double> tree, String s) -> {tree.add(Double.valueOf(s));},
(TreeSet<Double> tree, TreeSet<Double> s) -> {tree.addAll(s); return tree;}
)));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am using Janus(Third Party) Grid and getting the "System.StackOverflowException". Don't know how to solve it. I would like to appreciate for any help.
private void gridEX1_FormattingRow(object sender, RowLoadEventArgs e)
{
int index = e.Row.RowIndex;
try
{
if (!Convert.IsDBNull(gridEX1.GetRow(index).Cells["HEADER_ORDER_PACKAGE_ROW_ID"].Value))
{
if (Convert.ToInt32(gridEX1.GetRow(index).Cells["HEADER_ORDER_PACKAGE_ROW_ID"].Value) == PARENT_ORDER_PACKAGE_ID)
{
**gridEX1.MoveToRowIndex(index);**
GridEXRow curRow = gridEX1.GetRow();
if (curRow != null)
{
curRow.Expanded = true;
}
}
}
}
catch (Exception ex)
{
}
}
It seems that one of the lines inside your handler invoke the handler itself again. And so on, so you get StackOverflow.
I want to create an Oracle Spatial Geometry over JDBC with the following Statement:
//insert vorbereiten
try {
preStatement = conn.prepareStatement("insert into way(id, shape) "
+ "values(? ,SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(?)))");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
System.out.println("setString:");
preStatement.setString(1, "1");
Array a=conn.createArrayOf("double", new Object[]{9.23, 52.45, 9.67, 52.54});
preStatement.setArray(2, a);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But this does not work. Can someone please tell me how I can set the SDO_ORDINATE_ARRAY(?)-Values ?
I want to increment value of keyevent.VK parameter using program. I tried below code which print one "r.keyPress(KeyEvent.VK_1);" upon execution of this code it prints
1. I want program should automatically increase the values using any loop. please help
In this case the reflection API may be useful:
for (int i = 0; i < 9; i++) {
try {
final Field field = KeyEvent.class.getDeclaredField("VK_" + i);
r.keyPress((int) field.get(KeyEvent.class));
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}