Search in sources :

Example 21 with NotNull

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;
}
Also used : Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with NotNull

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);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) InetAddress(java.net.InetAddress) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with NotNull

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());
}
Also used : TextFieldWithHistory(com.intellij.ui.TextFieldWithHistory) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with NotNull

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;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 25 with NotNull

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()]);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) IDevice(com.android.ddmlib.IDevice) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)6249 VirtualFile (com.intellij.openapi.vfs.VirtualFile)829 ArrayList (java.util.ArrayList)617 Project (com.intellij.openapi.project.Project)540 File (java.io.File)531 PsiElement (com.intellij.psi.PsiElement)461 Nullable (org.jetbrains.annotations.Nullable)391 Module (com.intellij.openapi.module.Module)315 PsiFile (com.intellij.psi.PsiFile)296 List (java.util.List)272 IOException (java.io.IOException)263 TextRange (com.intellij.openapi.util.TextRange)245 ContainerUtil (com.intellij.util.containers.ContainerUtil)170 Document (com.intellij.openapi.editor.Document)158 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)154 ASTNode (com.intellij.lang.ASTNode)145 Pair (com.intellij.openapi.util.Pair)141 StringUtil (com.intellij.openapi.util.text.StringUtil)133 Logger (com.intellij.openapi.diagnostic.Logger)127 Editor (com.intellij.openapi.editor.Editor)120