Java tutorial
/* dCache - http://www.dcache.org/ * * Copyright (C) 2014 Deutsches Elektronen-Synchrotron * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.dcache.sf; import com.google.common.base.Joiner; import com.google.common.collect.Iterables; import java.io.IOException; import java.util.List; import java.util.Set; import org.dcache.pool.nearline.spi.StageRequest; import org.dcache.util.Checksum; import org.dcache.vehicles.FileAttributes; class StageTask implements PollingTask<Set<Checksum>> { public static final int ERROR_GRACE_PERIOD = 1000; StageTask(StageRequest request) { FileAttributes fileAttributes = request.getFileAttributes(); String id = fileAttributes.getPnfsId().toString(); } @Override public Set<Checksum> start() throws Exception { return null; } @Override public Set<Checksum> poll() throws IOException, InterruptedException, SfException { return null; } private SfException throwError(List<String> lines) throws SfException { String error; int errorCode; if (lines.isEmpty()) { errorCode = 1; error = "Sf ??? reported a stage failure without providing a reason."; } else { try { errorCode = Integer.parseInt(lines.get(0)); error = Joiner.on("\n").join(Iterables.skip(lines, 1)); } catch (NumberFormatException e) { errorCode = 1; error = Joiner.on("\n").join(lines); } } throw new SfException(errorCode, error); } @Override public boolean abort() throws Exception { return false; } }