Java 8 Monitor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Monitor class.

This code example shows how to use the following methods:setNotifyHigh, setThresholds, start, addObservedObject, setObservedAttribute
	public void setLowerThreshold(int lowerThreshold) {
		this.lowerThreshold = lowerThreshold;
	} 
 
	public GaugeMonitor getObject() throws Exception {
		GaugeMonitor monitor = new GaugeMonitor();
		monitor.setNotifyHigh(true);
		monitor.addObservedObject(new ObjectName(String.format("%s:type=JobExecution,name=%s,step=%s", defaultDomain,
				jobName, stepName)));
		monitor.setObservedAttribute(observedAttribute);
		if (observedAttribute.endsWith("Duration")) {
			monitor.setThresholds(new Double(upperThreshold), new Double(lowerThreshold));
		} 
		else { 
			monitor.setThresholds(new Integer(upperThreshold), new Integer(lowerThreshold));
		} 
		if (autoStart) {
			monitor.start();
		} 
		return monitor;

5
CodeRank
This code example shows how to use the following methods:sleep, addNotificationListener, setNotifyHigh, setNotifyLow, setThresholds
    /** 
     * Update the gauge and check for notifications 
     */ 
    public int gaugeMonitorNotification() throws Exception {
 
        GaugeMonitor gaugeMonitor = new GaugeMonitor();
        try { 
            // Create a new GaugeMonitor MBean and add it to the MBeanServer. 
            // 
            echo(">>> CREATE a new GaugeMonitor MBean"); 
            ObjectName gaugeMonitorName = new ObjectName(
                            domain + ":type=" + GaugeMonitor.class.getName());
            server.registerMBean(gaugeMonitor, gaugeMonitorName);
 
            echo(">>> ADD a listener to the GaugeMonitor"); 
            gaugeMonitor.addNotificationListener(this, null, null);
 
            // 
            // MANAGEMENT OF A STANDARD MBEAN 
            // 

3
CodeRank
This code example shows how to use the following methods:sleep, addNotificationListener, setNotifyHigh, setNotifyLow, setThresholds
    /** 
     * Update the gauge and check for notifications 
     */ 
    public int gaugeMonitorNotification() throws Exception {
 
        GaugeMonitor gaugeMonitor = new GaugeMonitor();
        try { 
            // Create a new GaugeMonitor MBean and add it to the MBeanServer. 
            // 
            echo(">>> CREATE a new GaugeMonitor MBean"); 
            ObjectName gaugeMonitorName = new ObjectName(
                            domain + ":type=" + GaugeMonitor.class.getName());
            server.registerMBean(gaugeMonitor, gaugeMonitorName);
 
            echo(">>> ADD a listener to the GaugeMonitor"); 
            gaugeMonitor.addNotificationListener(this, null, null);
 
            // 
            // MANAGEMENT OF A STANDARD MBEAN 
            // 

3
CodeRank
This code example shows how to use the following methods:start
                Subject subject = new Subject();
                echo(">>> RUN Principal = " + principals[i / 3]);
                subject.getPrincipals().add(new JMXPrincipal(principals[i / 3]));
                PrivilegedAction action = new PrivilegedAction() {
                    public Object run() { 
                        m.start();
                        return null; 
                    } 
                }; 
                Subject.doAs(subject, action);
            } 
 
            // Wait for all tasks to be submitted 
            // 
            try { 
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                echo("I fell asleep but someone woke me up"); 
                return 1; 
            } 
3
CodeRank
See Code Examples for Java 8 Monitor Methods: