Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Drop condor.chirp #36

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/main/java/edu/wisc/cs/will/Utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,7 @@ public static String limitLengthOfPrintedList(Map<?, ?> map) {
* Save some typing when throwing generic errors.
*/
public static void error(String msg) {
if ( CondorUtilities.isCondor() ) {
System.err.println("\nERROR: " + msg);
// Nice to print the calling stack so one can see what caused the error ...
// Doing it this way puts the stack in the ERROR file.
(new Exception()).printStackTrace();
println("\n" + msg);
println("\nSince this is a condor job, will exit.");
cleanupAndExit();
}
throw new WILLthrownError("\n " + msg);
throw new WILLthrownError("\n " + msg);
}
public static void error() {
throw new WILLthrownError("\n Should not happen ...");
Expand Down Expand Up @@ -450,9 +441,6 @@ public static void waitHere(String msg) {
print("\n% WaitHere: " + msg + "\n% ... Hit ENTER to continue or 'e' to interrupt. ", false);
doNotPrintToSystemDotOut = hold;

if ( CondorUtilities.isCondor() ) {
error("\nSince this is a condor job, will exit.");
}
try {
if (inBufferedReader == null) { inBufferedReader = new BufferedReader(new InputStreamReader(System.in)); }
String readThis = inBufferedReader.readLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class CompressedOutputStream extends OutputStream {

private OutputStream realStream;
private final OutputStream realStream;

public CompressedOutputStream(String fileName, boolean compressOutput) throws IOException {
this(new File(fileName), compressOutput);
Expand Down
112 changes: 4 additions & 108 deletions src/main/java/edu/wisc/cs/will/Utils/condor/CondorFile.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package edu.wisc.cs.will.Utils.condor;

import edu.wisc.cs.will.Utils.Utils;
import edu.wisc.cs.will.Utils.condor.chirp.ChirpClient;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
* @author twalker
*/
public class CondorFile extends File {

private static ChirpClient chirpClient;

static {
setupChirp();
}
Expand All @@ -33,188 +27,90 @@ public CondorFile(String pathname) {
}

private static void setupChirp() {
if (CondorUtilities.isChirp()) {
try {
chirpClient = new ChirpClient();
} catch (IOException ex) {
Logger.getLogger(CondorFile.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

@Override
public boolean canExecute() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.canExecute();
}

@Override
public boolean canRead() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.canRead();
}

@Override
public boolean canWrite() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.canWrite();
}

@Override
public boolean createNewFile() throws IOException {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.createNewFile();
}

@Override
public boolean delete() {
if (chirpClient != null) {
try {
if ( exists() ) {
chirpClient.unlink(getPath());
return true;
}
} catch (IOException ex) {
throw new RuntimeException("Condor/Chirp error deleting file " + getPath() + ":" + ex.toString());
}
return false;
}
else {
return super.delete();
}
return super.delete();
}

@Override
public boolean exists() {
if (chirpClient != null) {

try {
CondorFileInputStream is = new CondorFileInputStream(this);
try {
is.close();
} catch (IOException ignored) {
}
return true;

} catch (FileNotFoundException fileNotFoundException) {
return false;
}
}
else {
return super.exists();
}
return super.exists();
}

@Override
public long getTotalSpace() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.getTotalSpace();
}

@Override
public long getUsableSpace() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.getUsableSpace();
}

@Override
public boolean isDirectory() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.isDirectory();
}

@Override
public boolean isFile() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.isFile();
}

@Override
public long lastModified() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.lastModified();
}

@Override
public long length() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.length();
}

@Override
public String[] list() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.list();
}

@Override
public File[] listFiles() {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.listFiles();
}

@Override
public boolean mkdir() {
if (chirpClient != null) {
try {
chirpClient.mkdir(getPath());
return true;
} catch (IOException ex) {
throw new RuntimeException("Condor/Chirp failed to create " + getPath() + ".");
}
}
else {
return super.mkdir();
}
return super.mkdir();
}

@Override
public boolean mkdirs() {
if (chirpClient != null) {
if (!exists()) {
String parentString = getParent();
if (parentString != null) {
File parent = new CondorFile(parentString);
parent.mkdirs();
}

mkdir();
}

return true;
}
return super.mkdirs();
return super.mkdirs();
}

@Override
public boolean renameTo(File dest) {
if (chirpClient != null) {
throw new UnsupportedOperationException("Unsupported by Condor/Chirp.");
}
return super.renameTo(dest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.wisc.cs.will.Utils.condor;

import edu.wisc.cs.will.Utils.Utils;
import edu.wisc.cs.will.Utils.condor.chirp.ChirpInputStream;

import java.io.*;

Expand All @@ -10,35 +9,15 @@
*/
public class CondorFileInputStream extends InputStream {

private InputStream stream;
private final InputStream stream;

public CondorFileInputStream(File file) throws FileNotFoundException {
if (CondorUtilities.isChirp()) {
try {
stream = new ChirpInputStream(file.toString());
} catch (IOException ex) {
Utils.waitHere("Error opening Condor chirp stream for " + file + ".");
stream = null;
}
}
else {
stream = new FileInputStream(file);
}
stream = new FileInputStream(file);
}

public CondorFileInputStream(String fileName) throws FileNotFoundException {

if (CondorUtilities.isChirp()) {
try {
stream = new ChirpInputStream(Utils.replaceWildCards(fileName));
} catch (IOException ex) {
Utils.waitHere("Error opening Condor chirp stream for " + Utils.replaceWildCards(fileName) + ".");
stream = null;
}
}
else {
stream = new FileInputStream(Utils.replaceWildCards(fileName));
}
stream = new FileInputStream(Utils.replaceWildCards(fileName));
}

public long skip(long n) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.wisc.cs.will.Utils.condor;

import edu.wisc.cs.will.Utils.Utils;
import edu.wisc.cs.will.Utils.condor.chirp.ChirpOutputStream;

import java.io.*;

Expand All @@ -13,61 +12,21 @@ public class CondorFileOutputStream extends OutputStream {
private OutputStream stream;

public CondorFileOutputStream(File file) throws FileNotFoundException {
if (CondorUtilities.isChirp()) {
try {
stream = new ChirpOutputStream(file.toString());
} catch (IOException ex) {
stream = null;
throw new FileNotFoundException(ex.getMessage());
}
}
else {
stream = new FileOutputStream(file);
}
stream = new FileOutputStream(file);
}

public CondorFileOutputStream(String fileName) throws FileNotFoundException {

if (CondorUtilities.isChirp()) {
try {
stream = new ChirpOutputStream(Utils.replaceWildCards(fileName));
} catch (IOException ex) {
stream = null;
throw new FileNotFoundException(ex.getMessage());
}
}
else {
stream = new FileOutputStream(Utils.replaceWildCards(fileName));
}
stream = new FileOutputStream(Utils.replaceWildCards(fileName));
}

public CondorFileOutputStream(File file, boolean append) throws FileNotFoundException {
if (CondorUtilities.isChirp()) {
try {
stream = new ChirpOutputStream(file.toString(), append);
} catch (IOException ex) {
stream = null;
throw new FileNotFoundException(ex.getMessage());
}
}
else {
stream = new FileOutputStream(file, append);
}
stream = new FileOutputStream(file, append);
}

public CondorFileOutputStream(String fileName, boolean append) throws FileNotFoundException {

if (CondorUtilities.isChirp()) {
try {
stream = new ChirpOutputStream(Utils.replaceWildCards(fileName), append);
} catch (IOException ex) {
stream = null;
throw new FileNotFoundException(ex.getMessage());
}
}
else {
stream = new FileOutputStream(Utils.replaceWildCards(fileName), append);
}
stream = new FileOutputStream(Utils.replaceWildCards(fileName), append);
}

public void write(byte[] b, int off, int len) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class CondorFileReader extends Reader {

private Reader reader;
private final Reader reader;

public CondorFileReader(File file) throws FileNotFoundException {
reader = new InputStreamReader( new CondorFileInputStream(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class CondorFileWriter extends Writer {

private Writer writer;
private final Writer writer;

public CondorFileWriter(File file, boolean append) throws IOException {
writer = new OutputStreamWriter( new CondorFileOutputStream(file, append));
Expand Down
Loading