com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState Java Examples
The following examples show how to use
com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DirectoryScannerTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #2
Source File: ScanManagerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #3
Source File: ScanManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void schedule(long delay, long interval) { if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { LOG.fine("scheduling new task: state="+state); final ScanState old = switchState(SCHEDULED,"schedule"); final boolean scheduled = scheduleSession(new SessionTask(interval),delay); if (scheduled) LOG.fine("new task scheduled: state="+state); } finally { sequencer.release(); } sendQueuedNotifications(); }
Example #4
Source File: DirectoryScannerTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #5
Source File: ScanManagerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #6
Source File: ScanManager.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #7
Source File: DirectoryScannerTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #8
Source File: ScanManagerTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #9
Source File: DirectoryScannerTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #10
Source File: DirectoryScannerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #11
Source File: ScanManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #12
Source File: ScanManagerTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #13
Source File: DirectoryScannerTest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #14
Source File: ScanManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #15
Source File: DirectoryScannerTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #16
Source File: ScanManagerTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #17
Source File: ScanManagerTest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #18
Source File: ScanManager.java From hottub with GNU General Public License v2.0 | 6 votes |
public void schedule(long delay, long interval) { if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { LOG.fine("scheduling new task: state="+state); final ScanState old = switchState(SCHEDULED,"schedule"); final boolean scheduled = scheduleSession(new SessionTask(interval),delay); if (scheduled) LOG.fine("new task scheduled: state="+state); } finally { sequencer.release(); } sendQueuedNotifications(); }
Example #19
Source File: ScanManager.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void schedule(long delay, long interval) { if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { LOG.fine("scheduling new task: state="+state); final ScanState old = switchState(SCHEDULED,"schedule"); final boolean scheduled = scheduleSession(new SessionTask(interval),delay); if (scheduled) LOG.fine("new task scheduled: state="+state); } finally { sequencer.release(); } sendQueuedNotifications(); }
Example #20
Source File: ScanManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Enqueue a state changed notification for the given states. **/ private void queueStateChangedNotification( long sequence, long time, ScanState old, ScanState current) { final AttributeChangeNotification n = new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time, "ScanManager State changed to "+current,"State", ScanState.class.getName(),old.toString(),current.toString()); // Queue the notification. We have created an unlimited queue, so // this method should always succeed. try { if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) { LOG.fine("Can't queue Notification: "+n); } } catch (InterruptedException x) { LOG.fine("Can't queue Notification: "+x); } }
Example #21
Source File: DirectoryScannerTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #22
Source File: ScanManager.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #23
Source File: ScanManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Enqueue a state changed notification for the given states. **/ private void queueStateChangedNotification( long sequence, long time, ScanState old, ScanState current) { final AttributeChangeNotification n = new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time, "ScanManager State changed to "+current,"State", ScanState.class.getName(),old.toString(),current.toString()); // Queue the notification. We have created an unlimited queue, so // this method should always succeed. try { if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) { LOG.fine("Can't queue Notification: "+n); } } catch (InterruptedException x) { LOG.fine("Can't queue Notification: "+x); } }
Example #24
Source File: ScanManager.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #25
Source File: ScanManager.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Enqueue a state changed notification for the given states. **/ private void queueStateChangedNotification( long sequence, long time, ScanState old, ScanState current) { final AttributeChangeNotification n = new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time, "ScanManager State changed to "+current,"State", ScanState.class.getName(),old.toString(),current.toString()); // Queue the notification. We have created an unlimited queue, so // this method should always succeed. try { if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) { LOG.fine("Can't queue Notification: "+n); } } catch (InterruptedException x) { LOG.fine("Can't queue Notification: "+x); } }
Example #26
Source File: ScanManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Enqueue a state changed notification for the given states. **/ private void queueStateChangedNotification( long sequence, long time, ScanState old, ScanState current) { final AttributeChangeNotification n = new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time, "ScanManager State changed to "+current,"State", ScanState.class.getName(),old.toString(),current.toString()); // Queue the notification. We have created an unlimited queue, so // this method should always succeed. try { if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) { LOG.fine("Can't queue Notification: "+n); } } catch (InterruptedException x) { LOG.fine("Can't queue Notification: "+x); } }
Example #27
Source File: ScanManagerTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }
Example #28
Source File: ScanManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Checks that the current state is one of the allowed states, * and if so, switch its value to the new desired state. * This operation also enqueue the appropriate state changed * notification. **/ private ScanState switchState(ScanState desired,EnumSet<ScanState> allowed) { final ScanState old; final long timestamp; final long sequence; synchronized(this) { old = state; if (!allowed.contains(state)) throw new IllegalStateException(state.toString()); state = desired; timestamp = System.currentTimeMillis(); sequence = getNextSeqNumber(); } LOG.fine("switched state: "+old+" -> "+desired); if (old != desired) queueStateChangedNotification(sequence,timestamp,old,desired); return old; }
Example #29
Source File: ScanManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void schedule(long delay, long interval) { if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { LOG.fine("scheduling new task: state="+state); final ScanState old = switchState(SCHEDULED,"schedule"); final boolean scheduled = scheduleSession(new SessionTask(interval),delay); if (scheduled) LOG.fine("new task scheduled: state="+state); } finally { sequencer.release(); } sendQueuedNotifications(); }
Example #30
Source File: ScanManagerTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testGetState() throws IOException, InstanceNotFoundException { System.out.println("getState"); ScanManager instance = new ScanManager(); ScanState expResult = ScanState.STOPPED; ScanState result = instance.getState(); assertEquals(expResult, result); instance.start(); final ScanState afterStart = instance.getState(); assertContained(EnumSet.of(RUNNING,SCHEDULED,COMPLETED),afterStart); instance.stop(); assertEquals(STOPPED,instance.getState()); instance.schedule(1000000L,1000000L); assertEquals(SCHEDULED,instance.getState()); instance.stop(); assertEquals(STOPPED,instance.getState()); }