Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.gate.services
import com.netflix.spinnaker.gate.config.Service
import com.netflix.spinnaker.gate.config.ServiceConfiguration
import com.netflix.spinnaker.gate.services.internal.ClouddriverService
import com.netflix.spinnaker.gate.services.internal.ClouddriverServiceSelector
import com.netflix.spinnaker.gate.services.internal.Front50Service
import com.netflix.spinnaker.security.AuthenticatedRequest
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
import retrofit.RetrofitError
import retrofit.converter.ConversionException
import java.util.concurrent.Callable
import java.util.concurrent.ExecutionException
import java.util.concurrent.ExecutorService
import java.util.concurrent.Future
import java.util.concurrent.atomic.AtomicReference
@CompileStatic
@Component
@Slf4j
class ApplicationService {
@Autowired
ServiceConfiguration serviceConfiguration
@Autowired
ClouddriverServiceSelector clouddriverServiceSelector
@Autowired
Front50Service front50Service
@Autowired
ExecutorService executorService
private AtomicReference> allApplicationsCache = new AtomicReference<>([])
@Scheduled(fixedDelayString = '${services.front50.applicationRefreshIntervalMs:5000}')
void refreshApplicationsCache() {
try {
allApplicationsCache.set(tick(true))
log.debug("Refreshed Application List (applications: {})", allApplicationsCache.get().size())
} catch (e) {
log.error("Unable to refresh application list", e)
}
}
/**
* Fetching cluster details is a potentially expensive call to clouddriver, but allows us to
* provide a definitive list of accounts that an application has a presence in.
*
* As a trade-off, we'll fetch cluster details on the background refresh loop and merge in the
* account details when applications are requested on-demand.
*
* @param expandClusterNames Should cluster details (for each application) be fetched from clouddriver
* @return Applications
*/
List