- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
List<String> runningVmIds = new ArrayList<String>( );
for ( VmInfo runVm : request.getVms( ) ) {
runningVmIds.add( runVm.getInstanceId( ) );
}
for ( String vmId : VmInstances.getInstance( ).getKeys( ) ) {
if ( runningVmIds.contains( vmId ) ) {
continue;
}
VmInstance vm = null;
try {
vm = VmInstances.getInstance( ).lookup( vmId );
long splitTime = vm.getSplitTime( );
if ( splitTime > SHUT_DOWN_TIME ) {
VmInstances.getInstance( ).disable( vm.getName( ) );
vm.resetStopWatch( );
vm.setState( VmState.TERMINATED );
vm.setReason( INSTANCE_EXPIRED );
SystemState.cleanUp( vm );
}
} catch ( NoSuchElementException e ) {}
}
List<String> knownVmIds = new ArrayList<String>( );
knownVmIds.addAll( VmInstances.getInstance( ).getKeys( ) );
if ( knownVmIds.removeAll( runningVmIds ) ) {//<-- active registered vms not reported in describe
for ( String vmId : knownVmIds ) {
VmInstance vm = null;
try {
vm = VmInstances.getInstance( ).lookup( vmId );
long splitTime = vm.getSplitTime( );
if ( splitTime > SHUT_DOWN_TIME ) {
VmInstances.getInstance( ).disable( vm.getName( ) );
vm.resetStopWatch( );
vm.setState( VmState.TERMINATED );
vm.setReason( INSTANCE_EXPIRED );
SystemState.cleanUp( vm );
}
} catch ( NoSuchElementException e ) {
/* should never happen, just pulled the key set, if it does ignore it */
}
}
}
Я, наверно, тупой и ещё мало кофе с утра выпил, но мне кажется, что один из циклов тут явно лишний...
Lure Of Chaos 19.05.2010 13:25 # 0
OlegYch 19.05.2010 14:27 # +5