// Registra un MR para su gestion // curl -d "ip=192.168.119.35&port=10001&domain=broadcaster&type=Webservices" // http://192.168.119.35:9999/mbs/register @POST @Path("/register") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String register( @FormParam("ip") String ip, @FormParam("port") String port, @FormParam("domain") String domain, @FormParam("type") String type) { if (domain.equals("SNMPInstrumentingServer")) { Client client = Client.create(); WebResource webResource = client.resource( "http://" + MBeanServerMaster.INSTRUMENTING_SERVER_IP + ":" + MBeanServerMaster.INSTRUMENTING_SERVER_WS_PORT + "/snmp_mbs/register"); MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); queryParams.add("domain", "SNMPInstrumentingServer"); queryParams.add("type", type); ClientResponse s = webResource.queryParams(queryParams).post(ClientResponse.class, queryParams); if (s.getEntity(String.class).equals("ok")) DynamicMBeanMirrorFactory.register(ip, port, domain, type); } else DynamicMBeanMirrorFactory.register(ip, port, domain, type); return ""; }
// Remueve el registro de un MR // curl -d "ip=192.168.119.35&port=10001" -X DELETE // http://192.168.119.35:9999/mbs/broadcaster/Webservices @DELETE @Path("/{domain}/{type}") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String remove(@FormParam("ip") String ip, @FormParam("port") String port) { DynamicMBeanMirrorFactory.removeAll(ip, port); return ""; }
// Obtiene la descripción XML de un MA dado @GET @Path("/{domain}/{type}/{name}") @Produces(MediaType.TEXT_PLAIN) public String getMAInfo( @PathParam("domain") String domain, @PathParam("name") String name, @PathParam("type") String type) { return DynamicMBeanMirrorFactory.getMAInfo(domain, type, name); }
// Obtiene el valor de un atributo dado @GET @Path("/{domain}/{type}/{name}/{attribute}") @Produces(MediaType.TEXT_PLAIN) public String getAttribute( @PathParam("domain") String domain, @PathParam("name") String name, @PathParam("type") String type, @PathParam("attribute") String attribute) { return DynamicMBeanMirrorFactory.getAttribute(domain, name, type, attribute); }
// Cambia el estado de alerta de un MR dado // curl -X PUT http://192.168.119.35:9999/mbs/broadcaster/Webservices/alerts/{act|inact} @PUT @Path("/{domain}/{type}/alerts/{value}") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String setAlertable( @PathParam("domain") String domain, @PathParam("type") String type, @PathParam("value") String value) { return DynamicMBeanMirrorFactory.setAlertable(domain, type, value); }
// Modifica el valor de un atributo dado // curl -d "value=1111111" -X PUT http://192.168.119.35:9999/mbs/broadcaster/Webservices/ga1/voto @PUT @Path("/{domain}/{type}/{name}/{attribute}") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String setAttribute( @PathParam("domain") String domain, @PathParam("name") String name, @PathParam("type") String type, @PathParam("attribute") String attribute, @FormParam("value") String value) { return DynamicMBeanMirrorFactory.setAttribute(domain, name, type, attribute, value); }
// Modifica los valores los atributos de un grupo de atributos @PUT @Path("/{domain}/{type}/{name}/attributes") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public String setAttributes( @PathParam("domain") String domain, @PathParam("name") String name, @PathParam("type") String type, @FormParam("name") List<String> names, @FormParam("value") List<String> values) { HashMap<String, String> attrhm = new HashMap<String, String>(); for (int i = 0; i < names.size(); i++) { attrhm.put(names.get(i), values.get(i)); } return DynamicMBeanMirrorFactory.setAttributes(domain, name, type, attrhm); }