added index endpoint
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
package com.inteligr8.alfresco.asie.rest;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.asie.service.IndexService;
|
||||||
|
import com.inteligr8.alfresco.asie.spi.ActionCallback;
|
||||||
|
|
||||||
|
@Component(value = "webscript.com.inteligr8.alfresco.asie.indexAcsNode.post")
|
||||||
|
public class IndexAcsNodeWebScript extends AbstractAcsNodeActionWebScript {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IndexService indexSerivce;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeAction(long nodeDbId, ActionCallback callback, long fullQueueTimeout, TimeUnit fullQueueUnit,
|
||||||
|
long execTimeout, TimeUnit execUnit) throws TimeoutException, InterruptedException {
|
||||||
|
this.indexSerivce.index(nodeDbId, callback, 10L, TimeUnit.SECONDS, 30L, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.inteligr8.alfresco.asie.service;
|
||||||
|
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.asie.api.CoreAdminApi;
|
||||||
|
import com.inteligr8.alfresco.asie.model.ActionCoreResponse;
|
||||||
|
import com.inteligr8.alfresco.asie.model.core.IndexRequest;
|
||||||
|
import com.inteligr8.alfresco.asie.spi.ActionCallback;
|
||||||
|
import com.inteligr8.solr.model.Action;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class IndexService extends AbstractNodeActionService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getActionName() {
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getThreadNamePrefix() {
|
||||||
|
return "solr-index";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ActionCoreResponse<Action> execute(CoreAdminApi api, String core, long nodeDbId) {
|
||||||
|
IndexRequest apiRequest = new IndexRequest().withCore(core).withNodeId(nodeDbId);
|
||||||
|
return api.index(apiRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Future<Void> index(long nodeDbId, ActionCallback callback) throws InterruptedException {
|
||||||
|
return super.action(nodeDbId, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void index(long nodeDbId, ActionCallback callback, long fullQueueTimeout, TimeUnit fullQueueUnit,
|
||||||
|
long execTimeout, TimeUnit execUnit) throws TimeoutException, InterruptedException {
|
||||||
|
super.action(nodeDbId, callback, fullQueueTimeout, fullQueueUnit, execTimeout, execUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.inteligr8.alfresco.asie.spi;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.asie.model.ShardInstance;
|
||||||
|
|
||||||
|
public interface IndexCallback extends ActionCallback {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void unknownResult(ShardInstance instance) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
<webscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="https://bitbucket.org/!api/2.0/snippets/inteligr8/AzMgbp/80fdd26a6b3769a63cdc6b54bf1f39e378545cf7/files/snippet.txt">
|
||||||
|
|
||||||
|
<!-- Naming & Organization -->
|
||||||
|
<shortname>Index ACS Node in ASIE Indexes</shortname>
|
||||||
|
<family>Inteligr8 ASIE</family>
|
||||||
|
<description><![CDATA[
|
||||||
|
<p>Index the specified ACS node in the ASIE indexes.
|
||||||
|
This call will attempt to index the ACS node on all applicable Solr nodes.
|
||||||
|
The index operation could be synchronous or asynchronous and could fail on any Solr node.
|
||||||
|
If any Solr node failed synchronously in the execution, then expect a status code of 500.
|
||||||
|
The response body will still be identical to the 200/202 status codes.
|
||||||
|
If any Solr node is executing the index asynchronously and there are no synchronous failures, then expect a status code of 202.</p>
|
||||||
|
<p>The following path parameters are supported:</p>
|
||||||
|
<dl>
|
||||||
|
<dt>nodeId</dt>
|
||||||
|
<dd>An ACS node ID.</dd>
|
||||||
|
</dl>
|
||||||
|
<p>The following response body should be expected in most cases (200, 202, and 500 status codes):</p>
|
||||||
|
<pre>
|
||||||
|
{
|
||||||
|
"nodeDbId": number,
|
||||||
|
"success": [
|
||||||
|
"solrHostSync:8983/solr",
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"scheduled": [
|
||||||
|
"solrHostAsync:8983/solr",
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"error": [
|
||||||
|
"solrHostThatFailed:8983/solr": {
|
||||||
|
"message": "string"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
<p>The following status codes should be expected:</p>
|
||||||
|
<dl>
|
||||||
|
<dt>200</dt>
|
||||||
|
<dd>OK</dd>
|
||||||
|
<dt>202</dt>
|
||||||
|
<dd>Accepted</dd>
|
||||||
|
<dt>400</dt>
|
||||||
|
<dd>The path or query parameters are invalid</dd>
|
||||||
|
</dl>
|
||||||
|
]]></description>
|
||||||
|
|
||||||
|
<!-- Endpoint Configuration -->
|
||||||
|
<url>/inteligr8/asie/acs/node/{nodeId}/index</url>
|
||||||
|
<format default="json">any</format>
|
||||||
|
|
||||||
|
<!-- Security -->
|
||||||
|
<authentication>user</authentication>
|
||||||
|
|
||||||
|
<!-- Functionality -->
|
||||||
|
<cache>
|
||||||
|
<never>false</never>
|
||||||
|
<public>false</public>
|
||||||
|
</cache>
|
||||||
|
|
||||||
|
</webscript>
|
||||||
Reference in New Issue
Block a user