X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Ftoaster%2Fprovider%2FOpendaylightToaster.java;h=ea2ddc9b6558248f25ea7ae2bc7aec43f2f166f7;hb=7de815a866483636d621ba0953684a42c36f208e;hp=de5ddd9a75298f61d5c4ce15c00b9df0e170cc92;hpb=759e8399aedb07d0260140002f6e95e8ddd96a2c;p=controller.git diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java index de5ddd9a75..ea2ddc9b65 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java @@ -105,19 +105,19 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti ListenableFuture> future = t.commit(); Futures.addCallback( future, new FutureCallback>() { @Override - public void onSuccess( RpcResult result ) { + public void onSuccess( final RpcResult result ) { LOG.debug( "Delete Toaster commit result: " + result ); } @Override - public void onFailure( Throwable t ) { + public void onFailure( final Throwable t ) { LOG.error( "Delete of Toaster failed", t ); } } ); } } - private Toaster buildToaster( ToasterStatus status ) { + private Toaster buildToaster( final ToasterStatus status ) { // note - we are simulating a device whose manufacture and model are // fixed (embedded) into the hardware. @@ -193,20 +193,20 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti // to make toast. final ReadWriteTransaction tx = dataProvider.newReadWriteTransaction(); - ListenableFuture> readFuture = + ListenableFuture> readFuture = tx.read( LogicalDatastoreType.OPERATIONAL, TOASTER_IID ); final ListenableFuture> commitFuture = - Futures.transform( readFuture, new AsyncFunction, + Futures.transform( readFuture, new AsyncFunction, RpcResult>() { @Override public ListenableFuture> apply( - Optional toasterData ) throws Exception { + final Optional toasterData ) throws Exception { ToasterStatus toasterStatus = ToasterStatus.Up; if( toasterData.isPresent() ) { - toasterStatus = ((Toaster)toasterData.get()).getToasterStatus(); + toasterStatus = toasterData.get().getToasterStatus(); } LOG.debug( "Read toaster status: {}", toasterStatus ); @@ -242,7 +242,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti Futures.addCallback( commitFuture, new FutureCallback>() { @Override - public void onSuccess( RpcResult result ) { + public void onSuccess( final RpcResult result ) { if( result.getResult() == TransactionStatus.COMMITED ) { // OK to make toast @@ -262,7 +262,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti } @Override - public void onFailure( Throwable ex ) { + public void onFailure( final Throwable ex ) { if( ex instanceof OptimisticLockFailedException ) { // Another thread is likely trying to make toast simultaneously and updated the @@ -331,7 +331,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti Futures.addCallback( commitFuture, new FutureCallback>() { @Override - public void onSuccess( RpcResult result ) { + public void onSuccess( final RpcResult result ) { if( result.getResult() != TransactionStatus.COMMITED ) { LOG.error( "Failed to update toaster status: " + result.getErrors() ); } @@ -340,7 +340,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti } @Override - public void onFailure( Throwable t ) { + public void onFailure( final Throwable t ) { // We shouldn't get an OptimisticLockFailedException (or any ex) as no // other component should be updating the operational state. LOG.error( "Failed to update toaster status", t ); @@ -348,7 +348,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti notifyCallback( false ); } - void notifyCallback( boolean result ) { + void notifyCallback( final boolean result ) { if( resultCallback != null ) { resultCallback.apply( result ); } @@ -400,7 +400,7 @@ public class OpendaylightToaster implements ToasterService, ToasterProviderRunti setToasterStatusUp( new Function() { @Override - public Void apply( Boolean result ) { + public Void apply( final Boolean result ) { currentMakeToastTask.set( null );