1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */1819package org.apache.giraph.ooc.command;
2021import org.apache.giraph.ooc.OutOfCoreEngine;
2223import java.io.IOException;
24import java.util.concurrent.TimeUnit;
2526/**27 * IOCommand to do nothing regarding moving data to/from disk.28 */29publicclassWaitIOCommandextendsIOCommand {
30/** How long should the disk be idle? (in milliseconds) */31privatefinallong waitDuration;
3233/**34 * Constructor35 *36 * @param oocEngine out-of-core engine37 * @param waitDuration duration of wait38 */39publicWaitIOCommand(OutOfCoreEngine oocEngine, long waitDuration) {
40super(oocEngine, -1);
41this.waitDuration = waitDuration;
42 }
4344 @Override
45publicboolean execute() throws IOException {
46try {
47 TimeUnit.MILLISECONDS.sleep(waitDuration);
48 } catch (InterruptedException e) {
49thrownew IllegalStateException("execute: caught InterruptedException " +
50"while IO thread is waiting!");
51 }
52returntrue;
53 }
5455 @Override
56publicIOCommandType getType() {
57return IOCommandType.WAIT;
58 }
5960 @Override
61public String toString() {
62return"WaitIOCommand: (duration = " + waitDuration + "ms)";
63 }
64 }