Commit dc281aeb authored by Spiros Koulouzis's avatar Spiros Koulouzis

added timeout

parent d45e9d4b
......@@ -38,6 +38,24 @@ public interface ToscaTemplateApi {
@RequestMapping(value = "/manager/tosca_template/{id}",
method = RequestMethod.DELETE)
ResponseEntity<String> deleteToscaTemplateByID(@ApiParam(value = "ID of topology template to return", required = true) @PathVariable("id") String id, @ApiParam(value = "The node(s) to delete") @Valid @RequestParam(value = "node_name", required = false) List<String> nodeName);
@ApiOperation(value = "Deletes all tosca topology templates", nickname = "deleteAllToscaTemplates",
notes = "If the topology is provisoned it will delete the provison (Infrastructure). If it is deployed it will delete the deploymet too (Application)", response = String.class, authorizations = {
@Authorization(value = "auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class)
,
@ApiResponse(code = 404, message = "ToscaTemplate not found")})
@RequestMapping(value = "/manager/tosca_template/all",
method = RequestMethod.DELETE)
ResponseEntity<String> deleteAllToscaTemplates();
@ApiOperation(value = "Find topolog template by ID", nickname = "getToscaTemplateByID", notes = "Returns a single topolog template", response = String.class, authorizations = {
@Authorization(value = "auth", scopes = {
......
......@@ -68,6 +68,22 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
// }
}
@Override
public ResponseEntity<String> deleteAllToscaTemplates() {
List<String> ids = toscaTemplateService.getAllIds();
try {
for (String id : ids) {
dripService.delete(id, null);
}
return new ResponseEntity<>(HttpStatus.OK);
} catch (IOException | ApiException | TypeExeption | TimeoutException | InterruptedException ex) {
java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (NotFoundException ex) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@Override
public ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true)
@PathVariable("id") String id) {
......
......@@ -67,9 +67,9 @@ public class DRIPCaller implements AutoCloseable {
connection = factory.newConnection();
channel = connection.createChannel();
// create a single callback queue per client not per requests.
// Map<String, Object> args = new HashMap<String, Object>();
Map<String, Object> args = new HashMap<>();
// args.put("x-message-ttl", 60000);
// channel.queueDeclare("myqueue", false, false, false, args);
// replyQueueName = channel.queueDeclare("myqueue", false, false, false, args).getQueue();
replyQueueName = channel.queueDeclare().getQueue();
}
......@@ -139,9 +139,12 @@ public class DRIPCaller implements AutoCloseable {
if (getRequestQeueName().equals("provisioner")) {
timeOut = 10;
}
String resp = response.poll(timeOut, TimeUnit.MINUTES);
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", resp);
if (resp == null) {
getChannel().queueDeleteNoWait(getReplyQueueName(), false, true);
close();
throw new TimeoutException("Timeout on qeue: " + getRequestQeueName());
}
return mapper.readValue(resp, Message.class);
......
......@@ -165,10 +165,13 @@ public class DRIPService {
//If no nodes are specified delete all the infrastructure
if (nodeNames == null || nodeNames.isEmpty()) {
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies) {
toscaTemplate = setDesieredSate(toscaTemplate, vmTopology, NODE_STATES.DELETED);
if (vmTopologies != null) {
for (NodeTemplateMap vmTopology : vmTopologies) {
toscaTemplate = setDesieredSate(toscaTemplate, vmTopology, NODE_STATES.DELETED);
}
return execute(toscaTemplate, provisionerQueueName);
}
return execute(toscaTemplate, provisionerQueueName);
return id;
} else {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment