Package com.aerospike.client.async

Source Code of com.aerospike.client.async.AsyncWrite

/*
* Aerospike Client - Java Library
*
* Copyright 2013 by Aerospike, Inc. All rights reserved.
*
* Availability of this source code to partners and customers includes
* redistribution rights covered by individual contract. Please check your
* contract for exact rights and responsibilities.
*/
package com.aerospike.client.async;

import java.nio.ByteBuffer;

import com.aerospike.client.AerospikeException;
import com.aerospike.client.Key;
import com.aerospike.client.listener.WriteListener;

public final class AsyncWrite extends AsyncSingleCommand {
  private final WriteListener listener;
   
  public AsyncWrite(AsyncCluster cluster, Key key, WriteListener listener) {
    super(cluster, key);
    this.listener = listener;
  }

  protected void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
    int resultCode = byteBuffer.get(5) & 0xFF;
   
    if (resultCode != 0) {
      throw new AerospikeException(resultCode);
    }
  }

  protected void onSuccess() {
    if (listener != null) {
      listener.onSuccess(key);
    }
  } 

  protected void onFailure(AerospikeException e) {
    if (listener != null) {
      listener.onFailure(e);
    }
  }
}
TOP

Related Classes of com.aerospike.client.async.AsyncWrite

TOP
Copyright © 2018 www.massapi.com. 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.