当前位置: 首页>>代码示例>>Java>>正文


Java Objects.notNull方法代码示例

本文整理汇总了Java中io.fabric8.utils.Objects.notNull方法的典型用法代码示例。如果您正苦于以下问题:Java Objects.notNull方法的具体用法?Java Objects.notNull怎么用?Java Objects.notNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.fabric8.utils.Objects的用法示例。


在下文中一共展示了Objects.notNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDefaultDownloadStrategy

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
protected DownloadStrategy createDefaultDownloadStrategy() {
    return new DownloadStrategy() {
        @Override
        public File downloadContent(final OpenMavenURL sourceUrl, final File installDir) throws IOException {
            Objects.notNull(sourceUrl, "sourceUrl");
            // copy the URL to the install dir
            File archive = new File(installDir, INSTALLED_BINARY);
            InputStream from = sourceUrl.getInputStream(remoteRepositoryUrls);
            if (from == null) {
                throw new FileNotFoundException("Could not open URL: " + sourceUrl);
            }
            copy(from, new FileOutputStream(archive));
            return archive;
        }
    };
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:17,代码来源:ProcessManagerService.java

示例2: ServiceInstance

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
public ServiceInstance(Service service) {
    this.service = service;
    this.id = getName(service);
    ServiceSpec spec = KubernetesHelper.getOrCreateSpec(service);
    List<ServicePort> ports = spec.getPorts();
    if (spec.getPortalIP().equals(HEADLESS_PORTAL_IP)) {
        //do nothing service is headless
    } else if (ports != null && !ports.isEmpty()) {
        for (ServicePort servicePort : ports) {
            servicePorts.add(toNamedServicePort(id, servicePort));
        }
    } else {
        throw new IllegalArgumentException("Service: " + id + " doesn't have a valid port configuration.");
    }
    this.selector = KubernetesHelper.getSelector(service);
    Objects.notNull(this.selector, "No selector for service " + id);
    if (selector.isEmpty()) {
        throw new IllegalArgumentException("Empty selector for service " + id);
    }
    this.filter = KubernetesHelper.createPodFilter(selector);

    // TODO should we use some service metadata to choose the load balancer?
    this.loadBalancer = new RoundRobinLoadBalancer();
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:25,代码来源:ServiceInstance.java

示例3: generateArchetypesFromGithubOrganisation

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
/**
 * Iterates through all projects in the given github organisation and generates an archetype for it
 */
public void generateArchetypesFromGithubOrganisation(String githubOrg, File outputDir, List<String> dirs) throws IOException {
    GitHub github = GitHub.connectAnonymously();
    GHOrganization organization = github.getOrganization(githubOrg);
    Objects.notNull(organization, "No github organisation found for: " + githubOrg);
    Map<String, GHRepository> repositories = organization.getRepositories();
    Set<Map.Entry<String, GHRepository>> entries = repositories.entrySet();

    File cloneParentDir = new File(outputDir, "../git-clones");
    if (cloneParentDir.exists()) {
        Files.recursiveDelete(cloneParentDir);
    }
    for (Map.Entry<String, GHRepository> entry : entries) {
        String repoName = entry.getKey();
        GHRepository repo = entry.getValue();
        String url = repo.getGitTransportUrl();

        generateArchetypeFromGitRepo(outputDir, dirs, cloneParentDir, repoName, url, null);
    }
}
 
开发者ID:fabric8io,项目名称:ipaas-quickstarts,代码行数:23,代码来源:ArchetypeBuilder.java

示例4: subscribe

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
public SubscribeResponse subscribe(SubscribeRequest request) throws InternalException {
    String namespace = request.getNamespace();
    Objects.notNull(namespace, "namespace");

    ConfigMap configMap = createSubscriptionResource(request, namespace);
    kubernetesClient.configMaps().inNamespace(namespace).create(configMap);
    return new SubscribeResponse(namespace, KubernetesHelper.getName(configMap));
}
 
开发者ID:funktionio,项目名称:funktion-connectors,代码行数:9,代码来源:Agent.java

示例5: create

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
public static NamespaceName create(HasMetadata hasMetadata) {
    Objects.notNull(hasMetadata, "resource");
    ObjectMeta metadata = hasMetadata.getMetadata();
    Objects.notNull(metadata, "metadata");
    String name = metadata.getName();
    String namespace = metadata.getNamespace();
    Objects.notNull(name, "metadata.name");
    Objects.notNull(namespace, "metadata.namespace");
    return new NamespaceName(namespace, name);
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:11,代码来源:NamespaceName.java

示例6: getElasticsearchAPIForType

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
/**
 * Returns a REST client for the given API
 */
protected <T> T getElasticsearchAPIForType(Class<T> clazz) {
    T api = null;
    String url = getElasticsearchUrl();
    if (Strings.isNotBlank(url)) {
        api = createWebClient(clazz, url);
    }
    Objects.notNull(api, "No kubernetes service found for " + ELASTICSEARCH_SERVICE_NAME);
    return api;
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:13,代码来源:ElasticsearchClient.java

示例7: unpackBaseImage

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
protected void unpackBaseImage(File buildDir, boolean useDefaultPrefix) throws Exception {
    String imageName = project.getProperties().getProperty(DOCKER_BASE_IMAGE_PROPERTY);
    Objects.notNull(imageName, DOCKER_BASE_IMAGE_PROPERTY);

    ImageMavenCoords baseImageCoords = ImageMavenCoords.parse(imageName, useDefaultPrefix);
    String coords = baseImageCoords.getAetherCoords();

    Artifact artifact = repositorySystem.createArtifactWithClassifier(baseImageCoords.getGroupId(),
            baseImageCoords.getArtifactId(), baseImageCoords.getVersion(), baseImageCoords.getType(),
            baseImageCoords.getClassifier());
    getLog().info("Resolving Jube image: " + artifact);

    ArtifactResolutionRequest request = new ArtifactResolutionRequest();
    request.setArtifact(artifact);
    request.setLocalRepository(localRepository);
    request.setRemoteRepositories(pomRemoteRepositories);

    ArtifactResolutionResult result = artifactResolver.resolve(request);
    if (!result.isSuccess()) {
        throw new ArtifactNotFoundException("Cannot download Jube image", artifact);
    }

    getLog().info("Resolved Jube image: " + artifact);

    if (artifact.getFile() != null) {
        File file = artifact.getFile();
        getLog().info("File: " + file);

        if (!file.exists() || file.isDirectory()) {
            throw new MojoExecutionException("Resolved file for " + coords + " is not a valid file: " + file.getAbsolutePath());
        }
        getLog().info("Unpacking base image " + file.getAbsolutePath() + " to build dir: " + buildDir);
        Zips.unzip(new FileInputStream(file), buildDir);
    }
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:36,代码来源:BuildMojo.java

示例8: createMissingContainers

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
protected ImmutableList<Pod> createMissingContainers(ReplicationController replicationController, PodTemplateSpec podTemplateSpec,
                                                           ReplicationControllerSpec replicationControllerSpec, int createCount, List<Pod> pods) throws Exception {
    // TODO this is a hack ;) needs replacing with the real host we're creating on
    String host = ApiMasterService.getHostName();
    List<Pod> list = Lists.newArrayList(pods);
    for (int i = 0; i < createCount; i++) {
        Pod pod = new Pod();
        pod.setKind(NodeHelper.KIND_POD);

        createNewId(replicationController, pod);
        list.add(pod);

        List<Container> containers = KubernetesHelper.getContainers(podTemplateSpec);
        for (Container container : containers) {
            String containerName = getName(pod) + "-" + container.getName();

            ContainerStatus containerInfo = NodeHelper.getOrCreateContainerInfo(pod, containerName);
            PodStatus currentState = pod.getStatus();
            Objects.notNull(currentState, "currentState");
            currentState.setHostIP(host);

            String image = container.getImage();
            if (Strings.isBlank(image)) {
                LOG.warn("Missing image for " + containerName + " so cannot create it!");
                continue;
            }
            NodeHelper.addOrUpdateDesiredContainer(pod, containerName, container);
        }
        PodTemplateSpec podTemplate = replicationControllerSpec.getTemplate();
        if (podTemplate != null) {
            getOrCreateMetadata(pod).setLabels(KubernetesHelper.getLabels(podTemplate.getMetadata()));
        }
        // TODO should we update the pod now we've updated it?
        List<Container> desiredContainers = NodeHelper.getOrCreatePodDesiredContainers(pod);
        model.remoteCreatePod(pod);
    }
    return ImmutableList.copyOf(list);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:39,代码来源:Replicator.java

示例9: updateLocalPod

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
public String updateLocalPod(@NotNull final String podId, final Pod pod) throws Exception {
    System.out.println("Updating pod " + pod);
    PodSpec desiredState = pod.getSpec();
    Objects.notNull(desiredState, "desiredState");

    // lets ensure there's a default namespace set
    String namespace = KubernetesHelper.getNamespace(pod);
    if (Strings.isBlank(namespace)) {
        getOrCreateMetadata(pod).setNamespace(DEFAULT_NAMESPACE);
    }

    final PodStatus currentState = NodeHelper.getOrCreatetStatus(pod);
    final List<Container> containers = KubernetesHelper.getContainers(pod);

    NodeHelper.setPodWaiting(pod);
    NodeHelper.setContainerRunningState(pod, podId, false);

    model.updatePod(podId, pod);
    localCreateThreadPool.submit(new Runnable() {
        @Override
        public void run() {
            Runnable task = new Runnable() {
                @Override
                public void run() {
                    try {
                        NodeHelper.createMissingContainers(processManager, model, pod, currentState, containers);
                    } catch (Exception e) {
                        LOG.error("Failed to create container " + podId + ". " + e, e);
                    }

                }
            };
            NodeHelper.excludeFromProcessMonitor(processMonitor, pod, task);
        }
    });
    return getName(pod);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:38,代码来源:ApiMasterService.java

示例10: BuildConfigCollectors

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
public BuildConfigCollectors(BuildConfigProcessor buildConfigProcessor, long sleepPeriodMillis) {
    this.buildConfigProcessor = buildConfigProcessor;
    this.sleepPeriodMillis = sleepPeriodMillis;
    Objects.notNull(buildConfigProcessor, "buildConfigProcessor");
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:6,代码来源:BuildConfigCollectors.java

示例11: getMandatoryId

import io.fabric8.utils.Objects; //导入方法依赖的package包/类
protected String getMandatoryId(T entity) {
    String id = entityModel.getId(entity);
    Objects.notNull(id, "id for entity " + entity);
    return id;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:6,代码来源:ZkCacheModel.java


注:本文中的io.fabric8.utils.Objects.notNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。