use of org.jetbrains.annotations.NotNull in project cassandra-mesos-deprecated by mesosphere.
the class CassandraCluster method liveNodes.
@NotNull
public List<CassandraNode> liveNodes(int limit) {
final CassandraClusterState state = clusterState.get();
final int total = state.getNodesCount();
if (total == 0) {
return Collections.emptyList();
}
int totalLive = 0;
for (int i = 0; i < total; i++) {
if (isLiveNode(state.getNodes(i))) {
totalLive++;
}
}
limit = Math.min(totalLive, limit);
final ThreadLocalRandom tlr = ThreadLocalRandom.current();
final List<CassandraNode> result = new ArrayList<>(limit);
int misses = 0;
while (result.size() < limit && misses < 250) {
// the check for 250 misses is a poor-man's implementation to prevent a possible race-condition
final int i = tlr.nextInt(total);
final CassandraNode node = state.getNodes(i);
if (isLiveNode(node) && !result.contains(node)) {
result.add(node);
misses = 0;
} else {
misses++;
}
}
return result;
}
use of org.jetbrains.annotations.NotNull in project cassandra-mesos-deprecated by mesosphere.
the class CassandraCluster method buildCassandraNode.
@NotNull
private CassandraNode buildCassandraNode(@NotNull final Protos.Offer offer, final boolean seed, @Nullable final String replacementForIp) {
final CassandraNode.Builder builder = CassandraNode.newBuilder().setHostname(offer.getHostname()).setTargetRunState(CassandraNode.TargetRunState.RUN).addDataVolumes(DataVolume.newBuilder().setPath(configuration.getDefaultConfigRole().getPreDefinedDataDirectory())).setSeed(seed);
if (replacementForIp != null) {
builder.setReplacementForIp(replacementForIp);
}
builder.setRackDc(getRackDc(offer));
try {
final InetAddress ia = InetAddress.getByName(offer.getHostname());
int jmxPort = getPortMapping(PORT_JMX);
if (ia.isLoopbackAddress()) {
try (ServerSocket serverSocket = new ServerSocket(0)) {
jmxPort = serverSocket.getLocalPort();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
return builder.setIp(ia.getHostAddress()).setJmxConnect(JmxConnect.newBuilder().setIp("127.0.0.1").setJmxPort(jmxPort)).build();
} catch (final UnknownHostException e) {
throw new RuntimeException(e);
}
}
use of org.jetbrains.annotations.NotNull in project jscs-plugin by idok.
the class JscsSettingsPage method configJscsRcField.
private void configJscsRcField() {
TextFieldWithHistory textFieldWithHistory = configWithDefaults(jscsrcFile);
SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
@NotNull
public List<String> produce() {
return JscsFinder.searchForJscsRCFiles(getProjectPath());
}
});
SwingHelper.installFileCompletionAndBrowseDialog(project, jscsrcFile, "Select JSCS config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
use of org.jetbrains.annotations.NotNull in project jscs-plugin by idok.
the class JscsProjectComponent method validationFailed.
private void validationFailed(String msg) {
NotificationListener notificationListener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
JscsInspection.showSettings(project);
}
};
String errorMessage = msg + FIX_CONFIG_HREF;
showInfoNotification(errorMessage, NotificationType.WARNING, notificationListener);
LOG.debug(msg);
settingValidStatus = false;
}
use of org.jetbrains.annotations.NotNull in project adb-idea by pbreault.
the class MyDeviceChooser method getSelectedDevices.
@NotNull
public IDevice[] getSelectedDevices() {
int[] rows = mySelectedRows != null ? mySelectedRows : myDeviceTable.getSelectedRows();
List<IDevice> result = new ArrayList<IDevice>();
for (int row : rows) {
if (row >= 0) {
Object serial = myDeviceTable.getValueAt(row, SERIAL_COLUMN_INDEX);
final AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
if (bridge == null) {
return EMPTY_DEVICE_ARRAY;
}
IDevice[] devices = getFilteredDevices(bridge);
for (IDevice device : devices) {
if (device.getSerialNumber().equals(serial.toString())) {
result.add(device);
break;
}
}
}
}
return result.toArray(new IDevice[result.size()]);
}
Aggregations