Loading src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class PutFileController extends FileController { } try { fileDAO.setBusy(fileInfo.getNodeId(), true); fileDAO.setBusy(fileInfo.getNodeId(), jobId); Files.copy(is, file.toPath()); if (fileInfo.getContentType() == null) { Loading @@ -126,7 +126,7 @@ public class PutFileController extends FileController { } throw ex; } finally { fileDAO.setBusy(fileInfo.getNodeId(), false); fileDAO.setBusy(fileInfo.getNodeId(), null); } } Loading src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java +8 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import java.sql.Array; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -118,13 +119,17 @@ public class FileDAO { return Arrays.asList((String[]) array.getArray()); } public void setBusy(int nodeId, boolean busy) { public void setBusy(int nodeId, String jobId) { String sql = "UPDATE node SET busy_state = ? WHERE node_id = ?"; String sql = "UPDATE node SET job_id = ? WHERE node_id = ?"; jdbcTemplate.update(conn -> { PreparedStatement ps = conn.prepareStatement(sql); ps.setBoolean(1, busy); if (jobId == null) { ps.setNull(1, Types.VARCHAR); } else { ps.setString(1, jobId); } ps.setInt(2, nodeId); return ps; }); Loading Loading
src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class PutFileController extends FileController { } try { fileDAO.setBusy(fileInfo.getNodeId(), true); fileDAO.setBusy(fileInfo.getNodeId(), jobId); Files.copy(is, file.toPath()); if (fileInfo.getContentType() == null) { Loading @@ -126,7 +126,7 @@ public class PutFileController extends FileController { } throw ex; } finally { fileDAO.setBusy(fileInfo.getNodeId(), false); fileDAO.setBusy(fileInfo.getNodeId(), null); } } Loading
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java +8 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import java.sql.Array; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -118,13 +119,17 @@ public class FileDAO { return Arrays.asList((String[]) array.getArray()); } public void setBusy(int nodeId, boolean busy) { public void setBusy(int nodeId, String jobId) { String sql = "UPDATE node SET busy_state = ? WHERE node_id = ?"; String sql = "UPDATE node SET job_id = ? WHERE node_id = ?"; jdbcTemplate.update(conn -> { PreparedStatement ps = conn.prepareStatement(sql); ps.setBoolean(1, busy); if (jobId == null) { ps.setNull(1, Types.VARCHAR); } else { ps.setString(1, jobId); } ps.setInt(2, nodeId); return ps; }); Loading