Package org.rioproject.event

Examples of org.rioproject.event.RemoteServiceEvent


            if(eventNode==null) {
                tableData.clear();
                this.fireTableDataChanged();
                return;
            }
            RemoteServiceEvent event = eventNode.getEvent();
            tableData.clear();
            String impl = "<not declared>";
            Throwable thrown;
            if(event instanceof ProvisionFailureEvent) {
                String label = "ProvisionFailureEvent."+eventNode.getValueAt(0);
                ProvisionFailureEvent pfe = (ProvisionFailureEvent)event;
                ServiceElement elem = pfe.getServiceElement();
                if(elem.getComponentBundle()!=null)
                    impl = elem.getComponentBundle().getClassName();
                thrown = pfe.getThrowable();
                String exception = getExceptionText(thrown);
                tableData.put("Event", label);
                tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                tableData.put("Deployment", elem.getOperationalStringName());
                tableData.put("Service", elem.getName());
                tableData.put("Class", impl);
                StringBuilder builder = new StringBuilder();
                for(String reason : pfe.getFailureReasons()) {
                    if(builder.length()>0)
                        builder.append("\n    ");
                    builder.append(reason);
                }
                tableData.put("Reason", builder.toString());
                if(exception!=null) {
                    tableData.put("Exception", exception);
                    table.setRowHeight(tableData.size(), table.getRowHeight() * 20);
                }

            } else if(event instanceof ProvisionMonitorEvent) {
                String label = "ProvisionMonitorEvent."+eventNode.getValueAt(0);
                tableData.put("Event", label);
                ProvisionMonitorEvent pme = (ProvisionMonitorEvent)event;
                StringBuilder builder = new StringBuilder();
                if(pme.getAction().equals(ProvisionMonitorEvent.Action.OPSTRING_DEPLOYED) ||
                   pme.getAction().equals(ProvisionMonitorEvent.Action.OPSTRING_UNDEPLOYED)) {
                    StringBuilder serviceNameBuilder = new StringBuilder();
                    for(ServiceElement service : pme.getOperationalString().getServices()) {
                        if(serviceNameBuilder.length()>0) {
                            serviceNameBuilder.append(", ");
                        }
                        serviceNameBuilder.append(service.getName());
                    }
                    builder.append(serviceNameBuilder.toString());
                    tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                    tableData.put("Deployment", pme.getOperationalStringName());
                    tableData.put("Services", builder.toString());
                } else {
                    tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                    tableData.put("Deployment", pme.getOperationalStringName());
                    tableData.put("Description", eventNode.getDescription());
                }

            } else if(event instanceof ServiceLogEvent) {
                String label = "ServiceLogEvent."+eventNode.getValueAt(0);
                tableData.put("Event", label);
                ServiceLogEvent sle = (ServiceLogEvent)event;
                thrown = sle.getLogRecord().getThrown();
                String exception = getExceptionText(thrown);
                tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                tableData.put("Deployment", sle.getOpStringName());
                tableData.put("Service", sle.getServiceName());
                tableData.put("Machine", sle.getAddress().getHostName());
                tableData.put("Message", sle.getLogRecord().getLevel()+": "+sle.getLogRecord().getMessage());
                if(exception!=null) {
                    tableData.put("Exception", exception);
                    table.setRowHeight(tableData.size(), table.getRowHeight() * 20);
                }
            } else {
                String label = "SLAThresholdEvent."+eventNode.getValueAt(0);
                tableData.put("Event", label);
                SLAThresholdEvent slaEvent = (SLAThresholdEvent)event;
                StringBuilder builder = new StringBuilder();
                builder.append("low=").append(slaEvent.getSLA().getCurrentLowThreshold());
                builder.append(" high=").append(slaEvent.getSLA().getCurrentHighThreshold());
                tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                tableData.put("Deployment", slaEvent.getServiceElement().getOperationalStringName());
                tableData.put("Service", slaEvent.getServiceElement().getName());
                tableData.put("Machine", slaEvent.getHostAddress());
                tableData.put("Value", numberFormatter.format(slaEvent.getCalculable().getValue()));
                tableData.put("Threshold Values", builder.toString());
View Full Code Here


    class EventWriter implements Runnable {

        public void run() {
            while (true) {
                RemoteServiceEvent event;
                try {
                    event = eventWriteQ.take();
                } catch (InterruptedException e) {
                    logger.debug("EventWriter breaking out of main loop");
                    break;
                }
                File file = new File(persistentEventDirectory, createEventFileName(event));
                if(logger.isDebugEnabled())
                    logger.debug(String.format("Writing %s to %s", event, file.getPath()));
                ObjectOutputStream outputStream = null;
                try {
                    logger.debug(RMIClassLoader.getClassAnnotation(event.getClass()));
                    outputStream = new ObjectOutputStream(new FileOutputStream(file));
                    outputStream.writeObject(new RemoteServiceEventHolder(event));
                    if(logger.isDebugEnabled())
                        logger.debug(String.format("Wrote %d bytes to %s", file.length(), file.getPath()));
                } catch (IOException e) {
View Full Code Here

                                                           null));
    }

    @Test
    public void testPostNotify() throws Exception {
        RemoteServiceEvent event = new RemoteServiceEvent("Test Event");
        eventManager.notify(event);
        Assert.assertEquals(1, eventManager.getEvents().size());
    }
View Full Code Here

    }

    static List<RemoteServiceEvent> createRemoteServiceEvents(int count) {
        List<RemoteServiceEvent> list = new ArrayList<RemoteServiceEvent>();
        for(int i=0; i<count; i++) {
            RemoteServiceEvent event = new RemoteServiceEvent("Test Event "+i);
            event.setSequenceNumber(i);
            list.add(event);
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
View Full Code Here

    public RemoteServiceEventHolder(RemoteServiceEvent event) throws IOException {
        marshalledEvent = new MarshalledObject<RemoteServiceEvent>(event);
    }

    public RemoteServiceEvent getRemoteServiceEvent() throws ClassNotFoundException {
        RemoteServiceEvent remoteServiceEvent;
        try {
            remoteServiceEvent = marshalledEvent.get();
        } catch (IOException e) {
            throw new ClassNotFoundException("Failed to create client-side remote event", e);
        }
View Full Code Here

TOP

Related Classes of org.rioproject.event.RemoteServiceEvent

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.