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

Remove blackout #946

Merged
merged 2 commits into from
Apr 4, 2021
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
2 changes: 1 addition & 1 deletion VERSION.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10
0.11
14 changes: 0 additions & 14 deletions cuebot/src/main/java/com/imageworks/spcue/DeedEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ public class DeedEntity extends Entity {
public String host;
public String show;

/**
* The owner can set a black out time for booking where Cue will not
* automatically book the cores, even if NIMBY locked.
*
* This is measured in seconds past midnight.
*/
public int blackoutStart = 0;
public int blackoutStop = 0;

/**
* Quickly disable and enable the current black out time settings.
*/
public boolean isBlackoutEnabled = false;

public String getName() {
return String.format("%s.%s", owner, host);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ void insertLocalHostAssignment(HostInterface host, FrameInterface frame,
*/
boolean hasActiveLocalJob(HostInterface host);

/**
* Return true if the host is in blackout time.
*
* @param h
* @return
*/
boolean isBlackoutTime(HostInterface h);

/**
* Delete the given LocalHostAssignment.
*
Expand Down
16 changes: 0 additions & 16 deletions cuebot/src/main/java/com/imageworks/spcue/dao/DeedDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ public interface DeedDao {
*/
List<DeedEntity> getDeeds(OwnerEntity owner);

/**
* Enable/Disable the blackout time.
*
* @param value
*/
void updateBlackoutTimeEnabled(DeedEntity deed, boolean value);

/**
* Set blackout times. During blackout times, machines
* cannot be booked.
*
* @param start
* @param stop
*/
void setBlackoutTime(DeedEntity deed, int startSeconds, int stopSeconds);

/**
*
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,61 +250,6 @@ public boolean hasActiveLocalJob(HostInterface host) {
Integer.class, host.getHostId()) > 0;
}

private static final String IS_BLACKOUT_TIME =
"SELECT " +
"int_blackout_start,"+
"int_blackout_duration " +
"FROM " +
"host,"+
"deed "+
"WHERE " +
"host.pk_host = deed.pk_host " +
"AND " +
"deed.b_blackout = 1 " +
"AND " +
"host.pk_host = ? ";

public static final RowMapper<Boolean> BLACKOUT_MAPPER =
new RowMapper<Boolean>() {
public Boolean mapRow(final ResultSet rs, int rowNum) throws SQLException {

int startTimeSeconds = rs.getInt("int_backout_start");
int stopTimeSeconds = rs.getInt("int_blackout_stop");
if (stopTimeSeconds <= startTimeSeconds) {
stopTimeSeconds = stopTimeSeconds + 86400;
}

Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 0);
startTime.set(Calendar.MINUTE, 0);
startTime.set(Calendar.SECOND, 0);
startTime.add(Calendar.SECOND, startTimeSeconds);

Calendar stopTime = Calendar.getInstance();
stopTime.set(Calendar.HOUR_OF_DAY, 0);
stopTime.set(Calendar.MINUTE, 0);
stopTime.set(Calendar.SECOND, 0);
stopTime.add(Calendar.SECOND, stopTimeSeconds);

Calendar now = Calendar.getInstance();
if (now.compareTo(startTime) >= 0 && now.compareTo(stopTime) <= 0) {
return true;
}

return false;
}
};

@Override
public boolean isBlackoutTime(HostInterface h) {
try {
return getJdbcTemplate().queryForObject(IS_BLACKOUT_TIME,
BLACKOUT_MAPPER, h.getHostId());
} catch (Exception e) {
return false;
}
}

@Override
public int getCoreUsageDifference(LocalHostAssignment l, int coreUnits) {
return getJdbcTemplate().queryForObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public DeedEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
o.id = rs.getString("pk_deed");
o.owner = rs.getString("str_username");
o.host = rs.getString("str_hostname");
o.isBlackoutEnabled = rs.getBoolean("b_blackout");
o.blackoutStart = rs.getInt("int_blackout_start");
o.blackoutStop = rs.getInt("int_blackout_stop");
return o;
}
};
Expand Down Expand Up @@ -94,9 +91,6 @@ public DeedEntity insertDeed(OwnerEntity owner, HostInterface host) {
private static final String QUERY_FOR_DEED =
"SELECT " +
"deed.pk_deed, "+
"deed.b_blackout,"+
"deed.int_blackout_start,"+
"deed.int_blackout_stop, " +
"host.str_name as str_hostname, " +
"owner.str_username " +
"FROM " +
Expand All @@ -121,20 +115,5 @@ public List<DeedEntity> getDeeds(OwnerEntity owner) {
QUERY_FOR_DEED + " AND owner.pk_owner = ?",
DEED_MAPPER, owner.getId());
}

@Override
public void setBlackoutTime(DeedEntity deed, int startSeconds, int stopSeconds) {
getJdbcTemplate().update(
"UPDATE deed SET int_blackout_start = ?, " +
"int_blackout_stop = ? WHERE deed.pk_deed = ?",
startSeconds, stopSeconds, deed.getId());
}

@Override
public void updateBlackoutTimeEnabled(DeedEntity deed, boolean bool) {
getJdbcTemplate().update(
"UPDATE deed SET b_blackout = ? WHERE deed.pk_deed = ?",
bool, deed.getId());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,6 @@ public Deed mapRow(ResultSet rs, int rowNum) throws SQLException {
.setId(SqlUtil.getString(rs, "pk_deed"))
.setHost(SqlUtil.getString(rs, "str_host"))
.setOwner(SqlUtil.getString(rs, "str_username"))
.setBlackout(rs.getBoolean("b_blackout"))
.setBlackoutStartTime(rs.getInt("int_blackout_start"))
.setBlackoutStopTime(rs.getInt("int_blackout_stop"))
.build();
}
};
Expand Down Expand Up @@ -2166,9 +2163,6 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
"host.str_name AS str_host,"+
"show.str_name AS str_show,"+
"owner.str_username," +
"deed.b_blackout,"+
"deed.int_blackout_start,"+
"deed.int_blackout_stop,"+
"deed.pk_deed " +
"FROM " +
"deed,"+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,61 +250,6 @@ public boolean hasActiveLocalJob(HostInterface host) {
Integer.class, host.getHostId()) > 0;
}

private static final String IS_BLACKOUT_TIME =
"SELECT " +
"int_blackout_start,"+
"int_blackout_duration " +
"FROM " +
"host,"+
"deed "+
"WHERE " +
"host.pk_host = deed.pk_host " +
"AND " +
"deed.b_blackout = true " +
"AND " +
"host.pk_host = ? ";

public static final RowMapper<Boolean> BLACKOUT_MAPPER =
new RowMapper<Boolean>() {
public Boolean mapRow(final ResultSet rs, int rowNum) throws SQLException {

int startTimeSeconds = rs.getInt("int_backout_start");
int stopTimeSeconds = rs.getInt("int_blackout_stop");
if (stopTimeSeconds <= startTimeSeconds) {
stopTimeSeconds = stopTimeSeconds + 86400;
}

Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 0);
startTime.set(Calendar.MINUTE, 0);
startTime.set(Calendar.SECOND, 0);
startTime.add(Calendar.SECOND, startTimeSeconds);

Calendar stopTime = Calendar.getInstance();
stopTime.set(Calendar.HOUR_OF_DAY, 0);
stopTime.set(Calendar.MINUTE, 0);
stopTime.set(Calendar.SECOND, 0);
stopTime.add(Calendar.SECOND, stopTimeSeconds);

Calendar now = Calendar.getInstance();
if (now.compareTo(startTime) >= 0 && now.compareTo(stopTime) <= 0) {
return true;
}

return false;
}
};

@Override
public boolean isBlackoutTime(HostInterface h) {
try {
return getJdbcTemplate().queryForObject(IS_BLACKOUT_TIME,
BLACKOUT_MAPPER, h.getHostId());
} catch (Exception e) {
return false;
}
}

@Override
public int getCoreUsageDifference(LocalHostAssignment l, int coreUnits) {
return getJdbcTemplate().queryForObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public DeedEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
o.id = rs.getString("pk_deed");
o.owner = rs.getString("str_username");
o.host = rs.getString("str_hostname");
o.isBlackoutEnabled = rs.getBoolean("b_blackout");
o.blackoutStart = rs.getInt("int_blackout_start");
o.blackoutStop = rs.getInt("int_blackout_stop");
return o;
}
};
Expand Down Expand Up @@ -94,9 +91,6 @@ public DeedEntity insertDeed(OwnerEntity owner, HostInterface host) {
private static final String QUERY_FOR_DEED =
"SELECT " +
"deed.pk_deed, "+
"deed.b_blackout,"+
"deed.int_blackout_start,"+
"deed.int_blackout_stop, " +
"host.str_name as str_hostname, " +
"owner.str_username " +
"FROM " +
Expand All @@ -121,20 +115,5 @@ public List<DeedEntity> getDeeds(OwnerEntity owner) {
QUERY_FOR_DEED + " AND owner.pk_owner = ?",
DEED_MAPPER, owner.getId());
}

@Override
public void setBlackoutTime(DeedEntity deed, int startSeconds, int stopSeconds) {
getJdbcTemplate().update(
"UPDATE deed SET int_blackout_start = ?, " +
"int_blackout_stop = ? WHERE deed.pk_deed = ?",
startSeconds, stopSeconds, deed.getId());
}

@Override
public void updateBlackoutTimeEnabled(DeedEntity deed, boolean bool) {
getJdbcTemplate().update(
"UPDATE deed SET b_blackout = ? WHERE deed.pk_deed = ?",
bool, deed.getId());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,6 @@ public Deed mapRow(ResultSet rs, int rowNum) throws SQLException {
.setId(SqlUtil.getString(rs,"pk_deed"))
.setHost(SqlUtil.getString(rs,"str_host"))
.setOwner(SqlUtil.getString(rs,"str_username"))
.setBlackout(rs.getBoolean("b_blackout"))
.setBlackoutStartTime(rs.getInt("int_blackout_start"))
.setBlackoutStopTime(rs.getInt("int_blackout_stop"))
.build();
}
};
Expand Down Expand Up @@ -2160,9 +2157,6 @@ public Show mapRow(ResultSet rs, int rowNum) throws SQLException {
"host.str_name AS str_host,"+
"show.str_name AS str_show,"+
"owner.str_username," +
"deed.b_blackout,"+
"deed.int_blackout_start,"+
"deed.int_blackout_stop,"+
"deed.pk_deed " +
"FROM " +
"deed,"+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,6 @@ else if (!dispatchSupport.isCueBookable(host)) {
return;
}

/*
* Check for NIMBY blackout time.
*/
/*
if (bookingManager.isBlackOutTime(host)) {
logger.trace(host + " is blacked out.");
return ;
}
*/

/*
* Check if the host prefers a show. If it does , dispatch
* to that show first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
import com.imageworks.spcue.grpc.host.DeedGetOwnerRequest;
import com.imageworks.spcue.grpc.host.DeedGetOwnerResponse;
import com.imageworks.spcue.grpc.host.DeedInterfaceGrpc;
import com.imageworks.spcue.grpc.host.DeedSetBlackoutTimeEnabledRequest;
import com.imageworks.spcue.grpc.host.DeedSetBlackoutTimeEnabledResponse;
import com.imageworks.spcue.grpc.host.DeedSetBlackoutTimeRequest;
import com.imageworks.spcue.grpc.host.DeedSetBlackoutTimeResponse;
import com.imageworks.spcue.grpc.host.Host;
import com.imageworks.spcue.grpc.host.Owner;
import com.imageworks.spcue.service.OwnerManager;
Expand Down Expand Up @@ -65,23 +61,6 @@ public void getOwner(DeedGetOwnerRequest request, StreamObserver<DeedGetOwnerRes
responseObserver.onCompleted();
}

@Override
public void setBlackoutTime(DeedSetBlackoutTimeRequest request,
StreamObserver<DeedSetBlackoutTimeResponse> responseObserver) {
ownerManager.setBlackoutTime(toEntity(request.getDeed()), request.getStartTime(), request.getStopTime());
responseObserver.onNext(DeedSetBlackoutTimeResponse.newBuilder().build());
responseObserver.onCompleted();
}

@Override
public void setBlackoutTimeEnabled(DeedSetBlackoutTimeEnabledRequest request,
StreamObserver<DeedSetBlackoutTimeEnabledResponse> responseObserver) {
ownerManager.setBlackoutTimeEnabled(toEntity(request.getDeed()), request.getEnabled());
responseObserver.onNext(DeedSetBlackoutTimeEnabledResponse.newBuilder().build());
responseObserver.onCompleted();
}


public OwnerManager getOwnerManager() {
return ownerManager;
}
Expand All @@ -104,9 +83,6 @@ private DeedEntity toEntity(Deed deed) {
entity.host = deed.getHost();
entity.owner = deed.getOwner();
entity.show = deed.getShow();
entity.isBlackoutEnabled = deed.getBlackout();
entity.blackoutStart = deed.getBlackoutStartTime();
entity.blackoutStop = deed.getBlackoutStopTime();
return entity;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ public void createLocalHostAssignment(DispatchHost host,
*/
void removeInactiveLocalHostAssignment(LocalHostAssignment lha);

/**
*
* @param host
* @return
*/
boolean isBlackOutTime(HostInterface host);

/**
* Return true if the host is running more cores than the maximum allowed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ public void createLocalHostAssignment(DispatchHost host, FrameInterface frame,
bookingDao.insertLocalHostAssignment(host, frame, lja);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly=true)
public boolean isBlackOutTime(HostInterface host) {
return bookingDao.isBlackoutTime(host);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly=true)
public boolean hasResourceDeficit(HostInterface host) {
Expand Down
Loading