未验证 提交 171c4d7f 编写于 作者: O Oleg Nenashev 提交者: GitHub

Merge pull request #4388 from jglick/nullability-Label

Adding some nullability annotations related to Label
...@@ -71,6 +71,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext; ...@@ -71,6 +71,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import javax.annotation.Nonnull;
/** /**
* Group of {@link Node}s. * Group of {@link Node}s.
...@@ -84,16 +85,19 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod ...@@ -84,16 +85,19 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
/** /**
* Display name of this label. * Display name of this label.
*/ */
@Nonnull
protected transient final String name; protected transient final String name;
private transient volatile Set<Node> nodes; private transient volatile Set<Node> nodes;
private transient volatile Set<Cloud> clouds; private transient volatile Set<Cloud> clouds;
private transient volatile int tiedJobsCount; private transient volatile int tiedJobsCount;
@Exported @Exported
@Nonnull
public transient final LoadStatistics loadStatistics; public transient final LoadStatistics loadStatistics;
@Nonnull
public transient final NodeProvisioner nodeProvisioner; public transient final NodeProvisioner nodeProvisioner;
public Label(String name) { public Label(@Nonnull String name) {
this.name = name; this.name = name;
// passing these causes an infinite loop - getTotalExecutors(),getBusyExecutors()); // passing these causes an infinite loop - getTotalExecutors(),getBusyExecutors());
this.loadStatistics = new LoadStatistics(0,0) { this.loadStatistics = new LoadStatistics(0,0) {
...@@ -137,6 +141,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod ...@@ -137,6 +141,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
/** /**
* Returns a human-readable text that represents this label. * Returns a human-readable text that represents this label.
*/ */
@Nonnull
public String getDisplayName() { public String getDisplayName() {
return name; return name;
} }
......
...@@ -35,6 +35,7 @@ import jenkins.util.SystemProperties; ...@@ -35,6 +35,7 @@ import jenkins.util.SystemProperties;
import jenkins.util.Timer; import jenkins.util.Timer;
import org.jenkinsci.Symbol; import org.jenkinsci.Symbol;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.GuardedBy;
import java.awt.Color; import java.awt.Color;
...@@ -126,6 +127,7 @@ public class NodeProvisioner { ...@@ -126,6 +127,7 @@ public class NodeProvisioner {
* Null if this {@link NodeProvisioner} is working for the entire Hudson, * Null if this {@link NodeProvisioner} is working for the entire Hudson,
* for jobs that are unassigned to any particular node. * for jobs that are unassigned to any particular node.
*/ */
@CheckForNull
private final Label label; private final Label label;
private final AtomicReference<List<PlannedNode>> pendingLaunches private final AtomicReference<List<PlannedNode>> pendingLaunches
...@@ -149,7 +151,7 @@ public class NodeProvisioner { ...@@ -149,7 +151,7 @@ public class NodeProvisioner {
private final MultiStageTimeSeries plannedCapacitiesEMA = private final MultiStageTimeSeries plannedCapacitiesEMA =
new MultiStageTimeSeries(Messages._NodeProvisioner_EmptyString(),Color.WHITE,0,DECAY); new MultiStageTimeSeries(Messages._NodeProvisioner_EmptyString(),Color.WHITE,0,DECAY);
public NodeProvisioner(Label label, LoadStatistics loadStatistics) { public NodeProvisioner(@CheckForNull Label label, LoadStatistics loadStatistics) {
this.label = label; this.label = label;
this.stat = loadStatistics; this.stat = loadStatistics;
} }
...@@ -395,6 +397,7 @@ public class NodeProvisioner { ...@@ -395,6 +397,7 @@ public class NodeProvisioner {
/** /**
* The label under consideration. * The label under consideration.
*/ */
@CheckForNull
private final Label label; private final Label label;
/** /**
* The planned capacity for this {@link #label}. * The planned capacity for this {@link #label}.
...@@ -416,7 +419,7 @@ public class NodeProvisioner { ...@@ -416,7 +419,7 @@ public class NodeProvisioner {
* @param label the label. * @param label the label.
* @param plannedCapacitySnapshot the planned executor count. * @param plannedCapacitySnapshot the planned executor count.
*/ */
private StrategyState(LoadStatistics.LoadStatisticsSnapshot snapshot, Label label, int plannedCapacitySnapshot) { private StrategyState(LoadStatistics.LoadStatisticsSnapshot snapshot, @CheckForNull Label label, int plannedCapacitySnapshot) {
this.snapshot = snapshot; this.snapshot = snapshot;
this.label = label; this.label = label;
this.plannedCapacitySnapshot = plannedCapacitySnapshot; this.plannedCapacitySnapshot = plannedCapacitySnapshot;
...@@ -425,6 +428,7 @@ public class NodeProvisioner { ...@@ -425,6 +428,7 @@ public class NodeProvisioner {
/** /**
* The label under consideration. * The label under consideration.
*/ */
@CheckForNull
public Label getLabel() { public Label getLabel() {
return label; return label;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册