Commit 51f5c82b authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Used job_id instead of busy_state

parent 14e76602
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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) {
@@ -126,7 +126,7 @@ public class PutFileController extends FileController {
            }
            throw ex;
        } finally {
            fileDAO.setBusy(fileInfo.getNodeId(), false);
            fileDAO.setBusy(fileInfo.getNodeId(), null);
        }
    }

+8 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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;
        });