summaryrefslogtreecommitdiffstats
path: root/musictrigger
diff options
context:
space:
mode:
authorNelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>2018-11-14 15:50:17 -0500
committerNelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>2018-11-14 16:22:00 -0500
commitb9d442f62385f5e5f0b4c3f8ecf07e74109ffb9a (patch)
treed9d9b535192c5fd246ed446fe7888b3e932aa131 /musictrigger
parentb6dacb861d588690dd42e972b43752d90ad54dd0 (diff)
Fix last update for a casablanca release3.0.243.0.0-ONAP
Used wrong commit to cherry-pick into casablanca release. Pushing a fix. Also pushed MUSIC-157 Change-Id: I851bc43c79857de2d3d0517918344f7459be9043 Issue-ID: MUSIC-181 Signed-off-by: Nelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>
Diffstat (limited to 'musictrigger')
-rw-r--r--musictrigger/assembly.xml2
-rwxr-xr-xmusictrigger/src/MusicTrigger.java93
2 files changed, 42 insertions, 53 deletions
diff --git a/musictrigger/assembly.xml b/musictrigger/assembly.xml
index 90178d8f..34451eef 100644
--- a/musictrigger/assembly.xml
+++ b/musictrigger/assembly.xml
@@ -19,4 +19,4 @@
<outputDirectory>.</outputDirectory>
</fileSet>
</fileSets>
-</assembly>
+</assembly> \ No newline at end of file
diff --git a/musictrigger/src/MusicTrigger.java b/musictrigger/src/MusicTrigger.java
index b5894da1..eb79cb8c 100755
--- a/musictrigger/src/MusicTrigger.java
+++ b/musictrigger/src/MusicTrigger.java
@@ -51,15 +51,23 @@ import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
+
public class MusicTrigger implements ITrigger {
private static final Logger logger = LoggerFactory.getLogger(MusicTrigger.class);
-
public Collection<Mutation> augment(Partition partition)
{
+ new Thread(new Runnable() {
+ public void run() {
+ makeAsyncCall(partition);
+ }
+ }).start();
+ return Collections.emptyList();
+ }
+
+ private void makeAsyncCall(Partition partition) {
boolean isDelete = false;
- logger.info("Step 1: "+partition.partitionLevelDeletion().isLive());
if(partition.partitionLevelDeletion().isLive()) {
} else {
@@ -69,6 +77,7 @@ public class MusicTrigger implements ITrigger {
logger.info("MusicTrigger isDelete: " + isDelete);
String ksName = partition.metadata().ksName;
String tableName = partition.metadata().cfName;
+ String pkValue = partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey());
logger.info("MusicTrigger Table: " + tableName);
boolean isInsert = checkQueryType(partition);
org.json.simple.JSONObject obj = new org.json.simple.JSONObject();
@@ -121,7 +130,7 @@ public class MusicTrigger implements ITrigger {
}
}
} catch (Exception e) {
-
+ logger.info("Exception while constructing.. "+e.getMessage());
}
obj.put("updateList", updateList);
} else {
@@ -132,11 +141,12 @@ public class MusicTrigger implements ITrigger {
logger.info("Sending response: "+obj.toString());
try {
notifyMusic(obj.toString());
+ logger.info("MUSIC was notified.. "+obj.toString());
} catch(Exception e) {
- e.printStackTrace();
logger.error("Notification failed..."+e.getMessage());
+ logger.info("Notification failed..."+e.getMessage());
}
- return Collections.emptyList();
+
}
private int fromByteArray(byte[] bytes) {
@@ -160,62 +170,41 @@ public class MusicTrigger implements ITrigger {
}
private void notifyMusic(String request) {
- System.out.println("notifyMusic...");
+ logger.info("notifyMusic...");
Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/MUSIC/rest/v2/admin/callbackOps");
JSONObject data = new JSONObject();
data.setData(request);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
+ ClientResponse response = null;
+ try {
+ response = webResource.accept("application/json").type("application/json")
.post(ClientResponse.class, data);
+ } catch (Exception e) {
+ logger.info("Exception while notifying MUSIC. Retrying..");
+ try {
+ response = webResource.accept("application/json").type("application/json")
+ .post(ClientResponse.class, data);
+ } catch (Exception e1) {
+ logger.info("Exception while notifying MUSIC. Stopping retry attempts..");
+ }
+ }
if(response.getStatus() != 200){
- System.out.println("Exception while notifying MUSIC...");
+ logger.info("Exception while notifying MUSIC...");
+ try {
+ response = webResource.accept("application/json").type("application/json")
+ .post(ClientResponse.class, data);
+ } catch (Exception e) {
+ logger.info("Exception while notifying MUSIC. Retrying..");
+ try {
+ response = webResource.accept("application/json").type("application/json")
+ .post(ClientResponse.class, data);
+ } catch (Exception e1) {
+ logger.info("Exception while notifying MUSIC. Stopping retry attempts..");
+ }
+ }
}
- /*response.getHeaders().put(HttpHeaders.CONTENT_TYPE, Arrays.asList(MediaType.APPLICATION_JSON));
- response.bufferEntity();
- String x = response.getEntity(String.class);
- System.out.println("Response: "+x);*/
-
}
- /*public Collection<Mutation> augment(Partition partition) {
-
- String tableName = partition.metadata().cfName;
- System.out.println("Table: " + tableName);
-
- JSONObject obj = new JSONObject();
- obj.put("message_id", partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey()));
-
-
- try {
- UnfilteredRowIterator it = partition.unfilteredIterator();
- while (it.hasNext()) {
- Unfiltered un = it.next();
- Clustering clt = (Clustering) un.clustering();
- Iterator<Cell> cls = partition.getRow(clt).cells().iterator();
- Iterator<ColumnDefinition> columns = partition.getRow(clt).columns().iterator();
-
- while(cls.hasNext()){
- Cell cell = cls.next();
- String data = new String(cell.value().array()); // If cell type is text
- System.out.println(cell + " : " +data);
-
- }
- while(columns.hasNext()){
- ColumnDefinition columnDef = columns.next();
- Cell cell = cls.next();
- String data = new String(cell.value().array()); // If cell type is text
- obj.put(columnDef.toString(), data);
- }
- }
- } catch (Exception e) {
- }
-
- System.out.println(obj.toString());
-
- return Collections.emptyList();
- }*/
-
} \ No newline at end of file