Package org.apache.uima.ducc.transport.event

Examples of org.apache.uima.ducc.transport.event.ServiceReplyEvent


//    this.targetEndpoint = endpoint;
  }

    private ServiceReplyEvent failureEvent(String message)
    {
        return new ServiceReplyEvent(false, message, "no.endpoint", -1);
    }
View Full Code Here


            logger.error(methodName, null, "Crypto failure:", t.toString());
        }

        if ( ! validated ) {
            logger.warn(methodName, null, "User", user, "cannot be validated.", action, "rejected.");
            req.setReply(new ServiceReplyEvent(false, "User " + user + " cannot be validated. " + action + " rejected.", "NONE", -1));
            return false;
        }
        return true;
    }
View Full Code Here

        DuccId id = null;
        try {
            id = newId();
        } catch ( Exception e ) {
            logger.error(methodName, null, e);
            ev.setReply(new ServiceReplyEvent(false, "Internal error; unable to generate id", endpoint, -1));
            return;
        }
        logger.debug(methodName, id, "Unique:", id.getUnique());
                   
        String logdir = props.getProperty(UiOption.LogDirectory.pname());
        if ( !logdir.endsWith("/") ) {
            logdir = logdir + "/";
        }
        logdir = logdir + "S-" + id.toString();
        props.put(UiOption.LogDirectory.pname(), logdir);

        DuccProperties meta = new DuccProperties();
        meta.setProperty("user", user);
        meta.setProperty("instances", ""+instances);
        meta.setProperty("endpoint", endpoint);
        meta.setProperty("numeric_id", id.toString());
        meta.setProperty("uuid", id.getUnique());
        if ( autostart == Trinary.True ) {           
            meta.setProperty("autostart", "true");
        } else {
            meta.setProperty("autostart", "false");
        }

        String desc_name = descriptor_dir + "/" + id + ".svc";
        String meta_name = descriptor_dir + "/" + id + ".meta";
        ServiceReplyEvent reply = handler.register(id, desc_name, meta_name, props, meta);
        ev.setReply(reply);

        // Draw attentipn in the log on registration failures
        if ( reply.getReturnCode() ) {
            logger.info(methodName, id, ev.toString());
        } else {
            logger.warn(methodName, id, ev.toString());
        }
    }
View Full Code Here

        long id = ev.getFriendly();

        if ( ! validate_user("Unregister", ev) ) return;   // necessary messages emitted in here

        logger.info(methodName, null, "De-registering service", id);
        ServiceReplyEvent reply = handler.unregister(ev);
        ev.setReply(reply);      
    }
View Full Code Here

        String methodName = "startService";

        if ( ! validate_user("Start", ev) ) return;   // necessary messages emitted in here

        logger.info(methodName, null, "Starting service", ev.toString());
        ServiceReplyEvent reply = handler.start(ev);
        ev.setReply(reply);
        //ev.setReply(ServiceCode.OK, "Service not implemented.", "no-endpoint", null);
    }
View Full Code Here

        String methodName = "stopService";

        if ( ! validate_user("Stop", ev) ) return;   // necessary messages emitted in here

        logger.info(methodName, null, "Stopping service", ev.toString());
        ServiceReplyEvent reply = handler.stop(ev);
        ev.setReply(reply);
        //ev.setReply(ServiceCode.OK, "Service not implemented.", "no-endpoint", null);
    }
View Full Code Here

        String methodName = "modify";

        if ( ! validate_user("Modify", ev) ) return;   // necessary messages emitted in here

        logger.info(methodName, null, "Modify", ev.toString());
        ServiceReplyEvent reply = handler.modify(ev);
        ev.setReply(reply);
        //ev.setReply(ServiceCode.OK, "Service not implemented.", "no-endpoint", null);
    }
View Full Code Here

    {
            String methodName = "process";               
            try {
                logger.info(methodName, null, "Replying");
                AServiceRequest incoming =  (AServiceRequest) exchange.getIn().getBody();
                ServiceReplyEvent reply = incoming.getReply();
                exchange.getIn().setBody(reply);
            } catch ( Throwable t ) {
                logger.error(methodName, null, t);
            }
    }
View Full Code Here

       
        long friendly = ev.getFriendly();
        String epname = ev.getEndpoint();
        ServiceSet sset = serviceStateHandler.getServiceForApi(friendly, epname);
        if ( sset == null ) {
            return new ServiceReplyEvent(false, "Unknown", epname, friendly);
        }

        String userin = ev.getUser();
        String userout = sset.getUser();

        if ( !userin.equals(userout) && !serviceManager.isAdministrator(userin) ) {
            return new ServiceReplyEvent(false, "Owned by " + userout,  epname, friendly);
        }

        if ( sset.isRegistered() ) {
            int running = sset.countImplementors();
            int instances = ev.getInstances();
            int registered = sset.getNInstances();
            int wanted = 0;

            if ( instances == -1 ) {
                wanted = Math.max(0, registered - running);
            } else {
                wanted = instances;
            }
            if ( wanted == 0 ) {
                return new ServiceReplyEvent(true,
                                             "Already has instances[" + running + "] - no additional instances started",
                                             sset.getKey(),
                                             sset.getId().getFriendly());
            }

            pendingRequests.add(new ApiHandler(ev, this));

//             // only start something if we don't have enought already going
//             ApiHandler  apih = new ApiHandler(ev, this);
//             Thread t = new Thread(apih);
//             t.start();

            return new ServiceReplyEvent(true,
                                         "New instances[" + wanted + "]",
                                         sset.getKey(),
                                         sset.getId().getFriendly());
        } else {
            return new ServiceReplyEvent(false, "Not registered", sset.getKey(), sset.getId().getFriendly());     
        }
    }
View Full Code Here

    {
        long friendly = ev.getFriendly();
        String epname = ev.getEndpoint();
        ServiceSet sset = serviceStateHandler.getServiceForApi(friendly, epname);
        if ( sset == null ) {
            return new ServiceReplyEvent(false, "Unknown", epname, friendly);
        }

        String userin = ev.getUser();
        String userout = sset.getUser();

        if ( !userin.equals(userout) && !serviceManager.isAdministrator(userin) ) {
            return new ServiceReplyEvent(false, "Owned by " + userout,  epname, friendly);
        }

        if ( sset.isRegistered() ) {
            if ( sset.isStopped() ) {
                return new ServiceReplyEvent(false, "Already stopped", sset.getKey(), sset.getId().getFriendly());
            }

            pendingRequests.add(new ApiHandler(ev, this));
            return new ServiceReplyEvent(true, "Stopping", sset.getKey(), sset.getId().getFriendly());
        } else {
            return new ServiceReplyEvent(false, "Not registered", sset.getKey(), sset.getId().getFriendly());        
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.transport.event.ServiceReplyEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.