Coverage Report - org.apache.giraph.ooc.command.StorePartitionIOCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
StorePartitionIOCommand
0%
0/25
0%
0/6
1.75
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 package org.apache.giraph.ooc.command;
 20  
 
 21  
 import org.apache.giraph.bsp.BspService;
 22  
 import org.apache.giraph.comm.messages.MessageStore;
 23  
 import org.apache.giraph.ooc.data.DiskBackedEdgeStore;
 24  
 import org.apache.giraph.ooc.data.DiskBackedMessageStore;
 25  
 import org.apache.giraph.ooc.data.DiskBackedPartitionStore;
 26  
 import org.apache.giraph.ooc.OutOfCoreEngine;
 27  
 
 28  
 import java.io.IOException;
 29  
 
 30  
 /**
 31  
  * IOCommand to store partition data, edge data (if in INPUT_SUPERSTEP), and
 32  
  * message data (if in compute supersteps).
 33  
  */
 34  
 public class StorePartitionIOCommand extends IOCommand {
 35  
   /**
 36  
    * Constructor
 37  
    *
 38  
    * @param oocEngine out-of-core engine
 39  
    * @param partitionId id of the partition to store its data
 40  
    */
 41  
   public StorePartitionIOCommand(OutOfCoreEngine oocEngine,
 42  
                                  int partitionId) {
 43  0
     super(oocEngine, partitionId);
 44  0
   }
 45  
 
 46  
   @Override
 47  
   public boolean execute() throws IOException {
 48  0
     boolean executed = false;
 49  0
     if (oocEngine.getMetaPartitionManager()
 50  0
         .startOffloadingPartition(partitionId)) {
 51  0
       DiskBackedPartitionStore partitionStore =
 52  
           (DiskBackedPartitionStore)
 53  0
               oocEngine.getServerData().getPartitionStore();
 54  0
       numBytesTransferred +=
 55  0
           partitionStore.offloadPartitionData(partitionId);
 56  0
       if (oocEngine.getSuperstep() != BspService.INPUT_SUPERSTEP) {
 57  0
         MessageStore messageStore =
 58  0
             oocEngine.getServerData().getCurrentMessageStore();
 59  0
         if (messageStore != null) {
 60  0
           numBytesTransferred += ((DiskBackedMessageStore) messageStore)
 61  0
               .offloadPartitionData(partitionId);
 62  
         }
 63  0
       } else {
 64  0
         DiskBackedEdgeStore edgeStore =
 65  
             (DiskBackedEdgeStore)
 66  0
                 oocEngine.getServerData().getEdgeStore();
 67  0
         numBytesTransferred +=
 68  0
             edgeStore.offloadPartitionData(partitionId);
 69  
       }
 70  0
       oocEngine.getMetaPartitionManager().doneOffloadingPartition(partitionId);
 71  0
       executed = true;
 72  
     }
 73  0
     return executed;
 74  
   }
 75  
 
 76  
   @Override
 77  
   public IOCommandType getType() {
 78  0
     return IOCommandType.STORE_PARTITION;
 79  
   }
 80  
 
 81  
   @Override
 82  
   public String toString() {
 83  0
     return "StorePartitionIOCommand: (partitionId = " + partitionId + ")";
 84  
   }
 85  
 }