Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *    http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 package org.apache.spark.network.client;
0019 
0020 import org.apache.spark.network.buffer.ManagedBuffer;
0021 
0022 /**
0023  * Callback for the result of a single chunk result. For a single stream, the callbacks are
0024  * guaranteed to be called by the same thread in the same order as the requests for chunks were
0025  * made.
0026  *
0027  * Note that if a general stream failure occurs, all outstanding chunk requests may be failed.
0028  */
0029 public interface ChunkReceivedCallback {
0030   /**
0031    * Called upon receipt of a particular chunk.
0032    *
0033    * The given buffer will initially have a refcount of 1, but will be release()'d as soon as this
0034    * call returns. You must therefore either retain() the buffer or copy its contents before
0035    * returning.
0036    */
0037   void onSuccess(int chunkIndex, ManagedBuffer buffer);
0038 
0039   /**
0040    * Called upon failure to fetch a particular chunk. Note that this may actually be called due
0041    * to failure to fetch a prior chunk in this stream.
0042    *
0043    * After receiving a failure, the stream may or may not be valid. The client should not assume
0044    * that the server's side of the stream has been closed.
0045    */
0046   void onFailure(int chunkIndex, Throwable e);
0047 }