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


Java UriUtils.getLastPathSegment方法代码示例

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


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

示例1: getMetricLinkFragments

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Returns all the fragments of the metricLink.
 */
private static MetricKeyComponents getMetricLinkFragments(String metricLink) {
    metricLink = UriUtils.getLastPathSegment(metricLink);

    String[] linkFragments = metricLink.split(SEPARATOR);

    if (linkFragments.length != 2) {
        throw new IllegalArgumentException("Incorrect metric key format "
                + Arrays.toString(linkFragments)
                + ". Expected resource-id_timestamp.");
    }

    MetricKeyComponents metricKeyComponents = new MetricKeyComponents();
    metricKeyComponents.resourceId = linkFragments[0];
    metricKeyComponents.timestamp = linkFragments[1];
    return metricKeyComponents;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:StatsUtil.java

示例2: createNewIpAddressResource

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private IPAddressService.IPAddressState createNewIpAddressResource(String ipAddress,
        String subnetRangeLink,
        IPAddressService.IPAddressState.IPAddressStatus ipAddressStatus,
        String connectedResourceLink) {
    IPAddressService.IPAddressState ipAddressState = new IPAddressService.IPAddressState();
    ipAddressState.ipAddress = ipAddress;
    ipAddressState.ipAddressStatus = ipAddressStatus;
    if (ipAddressStatus == IPAddressStatus.ALLOCATED) {
        ipAddressState.connectedResourceLink = connectedResourceLink;
    }
    ipAddressState.subnetRangeLink = subnetRangeLink;
    ipAddressState.documentSelfLink = UriUtils.getLastPathSegment(subnetRangeLink) +
            IPAddressAllocationTaskService.ID_SEPARATOR + ipAddress;
    try {
        return postServiceSynchronously(IPAddressService.FACTORY_LINK, ipAddressState,
                IPAddressService.IPAddressState.class);
    } catch (Throwable throwable) {
        String message = String.format("Failed to create ip address %s due to error %s",
                ipAddress, throwable.getMessage());
        fail(message);
        return null;
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:IPAddressAllocationTaskServiceTest.java

示例3: logWithContext

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void logWithContext(AWSCostStatsCreationContext context, Level logLevel,
        Supplier<String> messageSupplier) {

    try {
        Supplier<String> wrapperMessageSupplierWithContext = () -> {
            String contextStr = null;
            if (context.endpointLink != null) {
                contextStr = UriUtils.getLastPathSegment(context.endpointLink);
            }
            return String.format("(AWS Cost %s): %s", contextStr, messageSupplier.get());
        };
        doLogging(logLevel, wrapperMessageSupplierWithContext);
    } catch (Exception e) {
        logWarning("Exception while logging.", e);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:AWSCostStatsService.java

示例4: updateComputeAndDiskStateForDetach

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Update compute and disk state for attach operation.
 */
private void updateComputeAndDiskStateForDetach(VSphereVMDiskContext ctx) {
    // Update the disk state to be AVAILABLE as it is detached successfully
    ctx.diskState.status = DiskService.DiskStatus.AVAILABLE;
    ctx.diskState.sourceImageReference = null;
    CustomProperties.of(ctx.diskState)
            .put(DISK_CONTROLLER_NUMBER, (String) null)
            .put(PROVIDER_DISK_UNIQUE_ID, (String) null);
    ctx.diskState.id = UriUtils.getLastPathSegment(ctx.diskState.documentSelfLink);

    // Remove the link from the compute state. Safety null check
    if (ctx.computeDesc.diskLinks != null) {
        ctx.computeDesc.diskLinks.remove(ctx.diskState.documentSelfLink);
    }

    OperationSequence.create(createDiskPut(ctx.diskState))
            .next(createComputePut(ctx))
            .next(ctx.mgr.createTaskPatch(TaskState.TaskStage.FINISHED))
            .setCompletion(ctx.failTaskOnError())
            .sendWith(this);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:VSphereComputeDiskManagementService.java

示例5: getStatsQueryTaskOperation

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Create a query task for each compute VM and return the operation.
 */
private Operation getStatsQueryTaskOperation(AzureStatsDataHolder statsData, String computeLink) {
    String computeId = UriUtils.getLastPathSegment(computeLink);
    String selfLink = UriUtils.buildUriPath(ResourceMetricsService.FACTORY_LINK, computeId);

    // TODO VSYM-3695: Limit the time boundaries on Azure metrics retrieval for each compute
    Query query = Query.Builder.create()
            .addKindFieldClause(ResourceMetrics.class)
            .addFieldClause(ServiceDocument.FIELD_NAME_SELF_LINK, selfLink, MatchType.PREFIX)
            .build();

    QueryTask queryTask = QueryTask.Builder.createDirectTask()
            .setQuery(query)
            .addOption(QueryOption.EXPAND_CONTENT)
            .addOption(QueryOption.TOP_RESULTS)
            .setResultLimit(QueryUtils.DEFAULT_MAX_RESULT_LIMIT)
            .build();
    queryTask.tenantLinks = statsData.computeHost.tenantLinks;

    return QueryUtils.createQueryTaskOperation(this, queryTask, ServiceTypeCluster.METRIC_SERVICE);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:AzureComputeHostStatsGatherer.java

示例6: loadRemoteNic

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private DeferredResult<Pair<NetworkInterfaceInner, String>> loadRemoteNic(
        Pair<NetworkInterfaceReferenceInner, String> pair, NetworkInterfacesInner netOps) {

    AzureDeferredResultServiceCallback<NetworkInterfaceInner> handler = new Default<>(
            this, "Getting Azure NIC: " + pair.getLeft().id());

    String networkInterfaceName = UriUtils.getLastPathSegment(pair.getLeft().id());
    String nicRG = getResourceGroupName(pair.getLeft().id());
    String resourceGroupName = getResourceGroupName(pair.getRight());
    if (!resourceGroupName.equalsIgnoreCase(nicRG)) {
        logWarning(
                "VM resource group %s is different from nic resource group %s, for nic %s",
                resourceGroupName, nicRG, pair.getLeft().id());
    }

    PhotonModelUtils.runInExecutor(this.executorService, () -> {
        netOps.getByResourceGroupAsync(resourceGroupName, networkInterfaceName,
                "ipConfigurations/publicIPAddress", handler);
    }, handler::failure);

    return handler.toDeferredResult()
            .thenApply(loaded -> Pair.of(loaded, pair.getRight()));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:AzureComputeEnumerationAdapterService.java

示例7: getAzureBlobName

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
public static String getAzureBlobName(ListBlobItem blob) {
    if (blob == null || blob.getUri() == null) {
        return EMPTY_STR;
    }

    String path = blob.getUri().getPath();
    if (!path.endsWith(UriUtils.URI_PATH_CHAR)) {
        return UriUtils.getLastPathSegment(blob.getUri());
    }

    String correctedUriPath = path.substring(0, path.length() - 1);
    URI correctedUri;
    try {
        correctedUri = new URI(correctedUriPath);
        return UriUtils.getLastPathSegment(correctedUri);
    } catch (URISyntaxException use) {
        return UriUtils.getLastPathSegment(blob.getUri());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:AzureStorageEnumerationAdapterService.java

示例8: stopEnumeration

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void stopEnumeration(EndpointRemovalTaskState currentState, SubStage next) {
    String id = UriUtils.getLastPathSegment(currentState.endpointLink);
    logFine(() -> String.format("Stopping any scheduled task for endpoint %s",
            currentState.endpointLink));
    Operation.createDelete(this, UriUtils.buildUriPath(ScheduledTaskService.FACTORY_LINK, id))
            .setCompletion((o, e) -> {
                if (e != null) {
                    logWarning(() -> String.format("Unable to delete ScheduleTaskState for"
                                    + " endpoint %s : %s", currentState.endpointLink,
                            e.getMessage()));
                }

                sendSelfPatch(TaskStage.STARTED, next);
            }).sendWith(this);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:16,代码来源:EndpointRemovalTaskService.java

示例9: generateIPAddressDocumentSelfLink

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private static String generateIPAddressDocumentSelfLink(String subnetRangeSelfLink,
        String ipAddress) {
    if (subnetRangeSelfLink == null || subnetRangeSelfLink.isEmpty()) {
        return ipAddress;
    }

    return UriUtils.getLastPathSegment(subnetRangeSelfLink) + ID_SEPARATOR + ipAddress;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:9,代码来源:IPAddressAllocationTaskService.java

示例10: processFailedOperations

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Process failed operation uris and adds to the list of metrics to be queried.
 */
private void processFailedOperations(SingleResourceStatsAggregationTaskState currentState,
        Map<String, Set<String>> metricsToBeQueried, URI uri) {
    String metricKey = UriUtils.getLastPathSegment(uri);
    String resourceId = stripRollupKey(metricKey);
    Set<String> metricKeys = new HashSet<>();
    for (Entry<String, Long> metricEntry : currentState.lastRollupTimeForMetric.entrySet()) {
        metricKeys.add(stripRollupKey(metricEntry.getKey()));
    }
    metricsToBeQueried.put(resourceId, metricKeys);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:14,代码来源:SingleResourceStatsAggregationTaskService.java

示例11: getLastCollectionMetricKeyForAdapterLink

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Forms the key to be used for looking up the last collection time for a given stats adapter.
 */
public String getLastCollectionMetricKeyForAdapterLink(String statsAdapterLink,
        boolean appendBucketSuffix) {
    String lastSuccessfulRunMetricKey = UriUtils.getLastPathSegment(statsAdapterLink) + StatsUtil.SEPARATOR
            + PhotonModelConstants.LAST_SUCCESSFUL_STATS_COLLECTION_TIME;
    if (appendBucketSuffix) {
        lastSuccessfulRunMetricKey = lastSuccessfulRunMetricKey + StatsConstants.MIN_SUFFIX;
    }
    return lastSuccessfulRunMetricKey;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:13,代码来源:SingleResourceStatsCollectionTaskService.java

示例12: getInMemoryMetrics

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Get in-memory metrics.
 */
private void getInMemoryMetrics(SingleResourceStatsAggregationTaskState currentState,
        QueryTask resourceQueryTask) {
    // Lookup in-memory metrics: /<resource-id><bucket> - /compute123(Hourly)
    List<Operation> operations = new ArrayList<>();
    for (String resourceLink : resourceQueryTask.results.documentLinks) {
        String resourceId = UriUtils.getLastPathSegment(resourceLink);
        List<String> rollupKeys = buildRollupKeys(resourceId);
        for (String rollupKey : rollupKeys) {
            String link = UriUtils
                    .buildUriPath(InMemoryResourceMetricService.FACTORY_LINK, rollupKey);
            operations.add(Operation.createGet(this, link));
        }
    }

    OperationJoin.create(operations.stream())
            .setCompletion((ops, exs) -> {
                // List of metrics we didn't find in memory and need to be queried from disk.
                Map<String, Set<String>> metricsToBeQueried = new HashMap<>();

                /*Nested map to store in memory stats
                {
                    ...
                    "CPUUtilization(Hourly)" : {
                        "1478040373000" : [
                            "TimeBin1",
                            "TimeBin2"
                        ],
                        "1478040505000" : [
                            "TimeBin3",
                            "TimeBin4"
                        ]
                    }
                    ...
                }*/
                Map<String, SortedMap<Long, List<TimeBin>>> inMemoryStats = new HashMap<>();

                for (Operation operation : ops.values()) {
                    if (operation.getStatusCode() != Operation.STATUS_CODE_OK) {
                        URI uri = operation.getUri();
                        Throwable ex = exs.get(operation.getId());
                        String msg = (ex == null) ? String.valueOf(operation.getStatusCode())
                                : ex.getMessage();
                        logFine(() -> String.format("In-memory metric lookup failed: %s with"
                                + " error %s", uri, msg));
                        processFailedOperations(currentState, metricsToBeQueried, uri);
                        continue;
                    }

                    InMemoryResourceMetric metric = operation
                            .getBody(InMemoryResourceMetric.class);

                    processInMemoryMetrics(currentState, metricsToBeQueried, inMemoryStats,
                            metric);
                }
                getRawMetrics(currentState, resourceQueryTask, metricsToBeQueried,
                        inMemoryStats);
            })
            .sendWith(this);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:63,代码来源:SingleResourceStatsAggregationTaskService.java

示例13: processInMemoryMetrics

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Process in-memory metrics.
 */
private void processInMemoryMetrics(SingleResourceStatsAggregationTaskState currentState,
        Map<String, Set<String>> metricsToBeQueried,
        Map<String, SortedMap<Long, List<TimeBin>>> inMemoryStats,
        InMemoryResourceMetric metric) {
    String metricKey = UriUtils.getLastPathSegment(metric.documentSelfLink);
    String resourceId = stripRollupKey(metricKey);

    for (Entry<String, Long> metricEntry : currentState.lastRollupTimeForMetric
            .entrySet()) {
        String rawMetricKey = stripRollupKey(metricEntry.getKey());

        TimeSeriesStats timeSeriesStats = metric.timeSeriesStats.get(rawMetricKey);

        // if there is no in-memory metric for this key then we don't have any
        // raw metrics; move on to the next metric
        if (timeSeriesStats == null) {
            continue;
        }

        // TODO VSYM-3190 - Change normalized interval boundary to beginning of the rollup period
        // Currently, xenon's time interval boundary 1 hour before than photon
        // model's aggregate metrics.
        Long earliestBinId = TimeUnit.MILLISECONDS.toMicros(timeSeriesStats.bins.firstKey());
        earliestBinId += TimeUnit.MILLISECONDS.toMicros(timeSeriesStats.binDurationMillis);

        Long lastRollupTime = metricEntry.getValue();

        // Check if we have any last rollup time or if rollup time is older than what we
        // have in memory.
        if (lastRollupTime == null || lastRollupTime < earliestBinId) {
            Set<String> metricList = metricsToBeQueried.get(resourceId);
            if (metricList == null) {
                metricList = new HashSet<>();
                metricsToBeQueried.put(resourceId, metricList);
            }
            metricList.add(rawMetricKey);
            continue;
        }
        processInMemoryTimeBins(currentState, inMemoryStats, metricEntry, timeSeriesStats);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:45,代码来源:SingleResourceStatsAggregationTaskService.java

示例14: getMetricKey

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
 * Builds a metric key for given resource link and timestamp.
 */
public static String getMetricKey(String resourceLink,
        Long sourceTimeMicrosUtc) {
    return UriUtils.getLastPathSegment(resourceLink) + SEPARATOR +
            + sourceTimeMicrosUtc;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:9,代码来源:StatsUtil.java

示例15: doTriggerEnumeration

import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void doTriggerEnumeration(EndpointAllocationTaskState currentState, SubStage next,
        URI adapterManagementReference) {
    EndpointState endpoint = currentState.endpointState;

    long intervalMicros = currentState.enumerationRequest.refreshIntervalMicros != null
            ? currentState.enumerationRequest.refreshIntervalMicros
            : DEFAULT_SCHEDULED_TASK_INTERVAL_MICROS;

    // Use endpoint documentSelfLink's last part as convention, so that we are able to stop
    // enumeration during endpoint update.
    String id = UriUtils.getLastPathSegment(endpoint.documentSelfLink);

    ResourceEnumerationTaskState enumTaskState = new ResourceEnumerationTaskState();
    enumTaskState.parentComputeLink = endpoint.computeLink;
    enumTaskState.endpointLink = endpoint.documentSelfLink;
    enumTaskState.resourcePoolLink = currentState.enumerationRequest.resourcePoolLink;
    enumTaskState.adapterManagementReference = adapterManagementReference;
    enumTaskState.tenantLinks = endpoint.tenantLinks;
    enumTaskState.options = EnumSet.of(TaskOption.SELF_DELETE_ON_COMPLETION);
    if (currentState.options.contains(TaskOption.IS_MOCK)) {
        enumTaskState.options.add(TaskOption.IS_MOCK);
    }
    if (currentState.options.contains(TaskOption.PRESERVE_MISSING_RESOUCES)) {
        enumTaskState.options.add(TaskOption.PRESERVE_MISSING_RESOUCES);
    }

    ScheduledTaskState scheduledTaskState = new ScheduledTaskState();
    scheduledTaskState.documentSelfLink = id;
    scheduledTaskState.factoryLink = ResourceEnumerationTaskService.FACTORY_LINK;
    scheduledTaskState.initialStateJson = Utils.toJson(enumTaskState);
    scheduledTaskState.intervalMicros = intervalMicros;
    scheduledTaskState.delayMicros = currentState.enumerationRequest.delayMicros;
    scheduledTaskState.noDelayOnInitialExecution = Boolean.TRUE;
    scheduledTaskState.tenantLinks = endpoint.tenantLinks;
    scheduledTaskState.customProperties = new HashMap<>();
    scheduledTaskState.customProperties.put(ENDPOINT_LINK_PROP_NAME,
            endpoint.documentSelfLink);

    Operation.createPost(this, ScheduledTaskService.FACTORY_LINK)
            .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE)
            .setBody(scheduledTaskState)
            .setCompletion((o, e) -> {
                if (e != null) {
                    logWarning(() -> String.format("Error triggering Enumeration task, reason:"
                            + " %s", e.getMessage()));
                }
                sendSelfPatch(createUpdateSubStageTask(next));
            })
            .sendWith(this);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:51,代码来源:EndpointAllocationTaskService.java


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