jetbrains.buildServer.util.EventDispatcher Java Examples
The following examples show how to use
jetbrains.buildServer.util.EventDispatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubePodNameGeneratorImpl.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
public KubePodNameGeneratorImpl(@NotNull ServerPaths serverPaths, @NotNull ExecutorServices executorServices, @NotNull EventDispatcher<BuildServerListener> eventDispatcher ){ myIdxStorage = new File(serverPaths.getPluginDataDirectory(), "kubeIdx"); if (!myIdxStorage.exists()){ myIdxStorage.mkdirs(); } if (!myIdxStorage.isDirectory()){ throw new CloudException("Unable to create a directory for kube plugin VM indexes"); } myIsAvailable = new AtomicBoolean(true); loadIdxes(myIdxStorage); eventDispatcher.addListener(new BuildServerAdapter(){ @Override public void serverShutdown() { myIsAvailable.set(false); storeIdxes(); } }); executorServices.getNormalExecutorService().scheduleWithFixedDelay(this::storeIdxes, 60, 60, TimeUnit.SECONDS); }
Example #2
Source File: SimpleRunContainerProviderTest.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
@BeforeMethod public void setUp() throws Exception { super.setUp(); myServerSettings = new ServerSettingsImpl(){ @Nullable @Override public String getServerUUID() { return "SERVER-UUID"; } }; final TempFiles tempFiles = new TempFiles(); myServerPaths = new ServerPaths(tempFiles.createTempDir()); myExecutorServices = new SimpleExecutorServices(); myEventDispatcher = EventDispatcher.create(BuildServerListener.class); myNameGenerator = new KubePodNameGeneratorImpl(myServerPaths, myExecutorServices, myEventDispatcher); myContainerProvider = new SimpleRunContainerProvider(myServerSettings); myPodTemplateProviders = new BuildAgentPodTemplateProvidersImpl(myServerSettings, (name, kubeClientParams) -> null); }
Example #3
Source File: DeploymentBuildAgentPodTemplateProviderTest.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
@BeforeMethod @Override protected void setUp() throws Exception { super.setUp(); m = new Mockery(); ServerSettings serverSettings = m.mock(ServerSettings.class); KubeAuthStrategyProvider authStrategies = m.mock(KubeAuthStrategyProvider.class); myDeploymentContentProvider = m.mock(DeploymentContentProvider.class); final ExecutorServices executorServices = m.mock(ExecutorServices.class); m.checking(new Expectations(){{ allowing(serverSettings).getServerUUID(); will(returnValue("server uuid")); allowing(authStrategies).get(with(UnauthorizedAccessStrategy.ID)); will(returnValue(myAuthStrategy)); ScheduledExecutorService ses = new ScheduledThreadPoolExecutor(1); allowing(executorServices).getNormalExecutorService(); will(returnValue(ses)); }}); TempFiles tempFiles = new TempFiles(); final ServerPaths serverPaths = new ServerPaths(tempFiles.createTempDir()); final EventDispatcher<BuildServerListener> eventDispatcher = EventDispatcher.create(BuildServerListener.class); myNameGenerator = new KubePodNameGeneratorImpl(serverPaths, executorServices, eventDispatcher); myPodTemplateProvider = new DeploymentBuildAgentPodTemplateProvider(serverSettings, myDeploymentContentProvider); }
Example #4
Source File: SQMSBuildFinishServiceFactory.java From TeamCity.SonarQubePlugin with Apache License 2.0 | 6 votes |
public SQMSBuildFinishServiceFactory(@NotNull final SQMSBuildFinishRunner sqmsBuildStartRunner, @NotNull final OSType osType, @NotNull final MonoLocator monoLocator, @NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher, @NotNull final CurrentBuildTracker currentBuildTracker) { mySQMSBuildFinishRunner = sqmsBuildStartRunner; myOSType = osType; myMonoLocator = monoLocator; myCurrentBuildTracker = currentBuildTracker; dispatcher.addListener(new AgentLifeCycleAdapter() { @Override public void buildStarted(@NotNull final AgentRunningBuild runningBuild) { myMSBuildScannerLocator = null; myWorkingDirectory = null; mySqrParametersAccessor = null; } @Override public void runnerFinished(@NotNull final BuildRunnerContext runner, @NotNull final BuildFinishedStatus status) { if (runner.getRunType().equals(mySQMSBuildFinishRunner.getType())) { myMSBuildScannerLocator = null; myWorkingDirectory = null; mySqrParametersAccessor = null; } } }); }
Example #5
Source File: UserUIDAndGIDImpl.java From TeamCity.Virtual with Apache License 2.0 | 6 votes |
public UserUIDAndGIDImpl(@NotNull final EventDispatcher<AgentLifeCycleListener> events) { events.addListener(new AgentLifeCycleAdapter(){ @Override public void afterAgentConfigurationLoaded(@NotNull final BuildAgent agent) { final BuildAgentConfiguration configuration = agent.getConfiguration(); if (configuration.getConfigurationParameters().get(VMConstants.DOCKER_PROPERTY) == null) return; if (!configuration.getSystemInfo().isUnix()) return; if (configuration.getSystemInfo().isWindows()) return; if (configuration.getSystemInfo().isMac()) return; detectSidAndGid(); } }); }
Example #6
Source File: ReportsFeature.java From appengine-tck with Apache License 2.0 | 6 votes |
public ReportsFeature(EventDispatcher<BuildServerListener> dispatcher, @NotNull ReportsDescriptor descriptor, @NotNull ReportsConstants constants) { this.editParametersUrl = descriptor.getFeaturePath(); this.constants = constants; this.jsonFactory = JacksonFactory.getDefaultInstance(); try { this.httpTransport = GoogleNetHttpTransport.newTrustedTransport(); } catch (GeneralSecurityException | IOException e) { throw new RuntimeException(e); } if (dispatcher != null) { dispatcher.addListener(new BuildServerAdapter() { @Override public void buildFinished(SRunningBuild build) { handleBuildFinished(build); } }); } }
Example #7
Source File: S3ArtifactsPublisher.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
public S3ArtifactsPublisher(@NotNull final AgentArtifactHelper helper, @NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher, @NotNull final CurrentBuildTracker tracker, @NotNull final BuildAgentConfiguration buildAgentConfiguration) { myHelper = helper; myTracker = tracker; myBuildAgentConfiguration = buildAgentConfiguration; dispatcher.addListener(new AgentLifeCycleAdapter() { @Override public void buildStarted(@NotNull final AgentRunningBuild runningBuild) { myFileUploader = null; myArtifacts.clear(); } }); }
Example #8
Source File: Agent.java From TeamCity-Phabricator-Plugin with MIT License | 5 votes |
public Agent( @NotNull final EventDispatcher<AgentLifeCycleListener> eventDispatcher, @NotNull final PhabLogger phabLogger, @NotNull final AppConfig appConfig ){ eventDispatcher.addListener(this); this.logger = phabLogger; this.appConfig = appConfig; this.logger.info("Instantiated"); }
Example #9
Source File: Server.java From TeamCity-Phabricator-Plugin with MIT License | 5 votes |
public Server( @NotNull final EventDispatcher<BuildServerListener> buildServerListener, @NotNull final PhabLogger logger ){ buildServerListener.addListener(this); this.logger = logger; Loggers.SERVER.info("Phab Server Initialized"); }
Example #10
Source File: SQMSBuildStartServiceFactory.java From TeamCity.SonarQubePlugin with Apache License 2.0 | 5 votes |
public SQMSBuildStartServiceFactory(@NotNull final SQMSBuildStartRunner sqmsBuildStartRunner, @NotNull final OSType osType, @NotNull final MonoLocator monoLocator, @NotNull final SQMSBuildFinishServiceFactory sqmsBuildFinishServiceFactory, @NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher) { mySQMSBuildStartRunner = sqmsBuildStartRunner; myOSType = osType; myMonoLocator = monoLocator; mySqmsBuildFinishServiceFactory = sqmsBuildFinishServiceFactory; mySonarQubeMSBuildScannerLocator = new SonarQubeMSBuildScannerLocatorImpl(); dispatcher.addListener(new AgentLifeCycleAdapter() { @Override public void beforeRunnerStart(@NotNull final BuildRunnerContext runner) { if (runner.getRunType().equals(mySQMSBuildStartRunner.getType())) { mySqmsBuildFinishServiceFactory.setUpFinishStep(new SonarQubeMSBuildScannerLocator() { @Nullable @Override public String getExecutablePath(@NotNull final BuildRunnerContext runnerContext) throws RunBuildException { return mySonarQubeMSBuildScannerLocator.getExecutablePath(runner); } }, runner.getWorkingDirectory(), new SQRParametersAccessor(SQRParametersUtil.mergeAuthParameters(runner.getBuild().getSharedConfigParameters(), runner.getRunnerParameters()))); } } }); }
Example #11
Source File: KubeAgentConfigurationProvider.java From teamcity-kubernetes-plugin with Apache License 2.0 | 4 votes |
public KubeAgentConfigurationProvider(@NotNull EventDispatcher<AgentLifeCycleListener> agentEvents, @NotNull final BuildAgentConfigurationEx agentConfigurationEx) { LOG.info("Initializing Kube Provider..."); agentEvents.addListener(new AgentLifeCycleAdapter(){ @Override public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) { super.afterAgentConfigurationLoaded(agent); final Map<String, String> env = System.getenv(); final String providedServerUrl = env.get(KubeContainerEnvironment.SERVER_URL); if(StringUtil.isNotEmpty(providedServerUrl)) { LOG.info("Provided TeamCity Server URL: " + providedServerUrl); agentConfigurationEx.setServerUrl(providedServerUrl); } else { LOG.info("TeamCity Server URL was not provided. The instance wasn't started using TeamCity Kube integration."); return; } final String profileId = env.get(KubeContainerEnvironment.PROFILE_ID); if(StringUtil.isNotEmpty(profileId)){ LOG.info("Provided Profile Id: " + profileId); agentConfigurationEx.addConfigurationParameter(KubeContainerEnvironment.REQUIRED_PROFILE_ID_CONFIG_PARAM, profileId); } else { LOG.info("Profile Id was not provided. The instance wasn't started using TeamCity Kube integration."); return; } final String instanceName = env.get(KubeContainerEnvironment.INSTANCE_NAME); if (StringUtil.isNotEmpty(instanceName)) { LOG.info("Setting instance name to " + instanceName); agentConfigurationEx.setName(instanceName); } else { LOG.warn("Couldn't find 'env." + KubeContainerEnvironment.INSTANCE_NAME + "' property" ); } for (Map.Entry<String, String> entry : env.entrySet()){ final String key = entry.getKey(); final String value = entry.getValue(); if (key.startsWith(TEAMCITY_KUBERNETES_PROVIDED_PREFIX)){ LOG.info("prop( " + key + ") : " + value); agentConfigurationEx.addConfigurationParameter(key.substring(TEAMCITY_KUBERNETES_PROVIDED_PREFIX.length()), value); } } } }); }
Example #12
Source File: WinDbgToolsDetector.java From teamcity-symbol-server with Apache License 2.0 | 4 votes |
public WinDbgToolsDetector(@NotNull final EventDispatcher<AgentLifeCycleListener> events, @NotNull final Win32RegistryAccessor registryAccessor) { myRegistryAccessor = registryAccessor; events.addListener(this); }
Example #13
Source File: AnsibleReportArtifatcsProvider.java From tc-ansible-runner with MIT License | 4 votes |
public AnsibleReportArtifatcsProvider( @NotNull ArtifactsWatcher artifactsWatcher, @NotNull EventDispatcher<AgentLifeCycleListener> agentDispatcher) { agentDispatcher.addListener(this); this.artifactsWatcher = artifactsWatcher; }
Example #14
Source File: BuildBreakerProblemListener.java From TeamCity.SonarQubePlugin with Apache License 2.0 | 4 votes |
public BuildBreakerProblemListener(@NotNull final EventDispatcher<AgentLifeCycleListener> agentDispatcher) { agentDispatcher.addListener(this); }
Example #15
Source File: SonarProcessListener.java From TeamCity.SonarQubePlugin with Apache License 2.0 | 4 votes |
public SonarProcessListener(@NotNull final EventDispatcher<AgentLifeCycleListener> agentDispatcher, @NotNull final ArtifactsWatcher watcher) { myWatcher = watcher; agentDispatcher.addListener(this); }
Example #16
Source File: VMWarePropertiesReader.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public VMWarePropertiesReader(final BuildAgentConfigurationEx agentConfiguration, @NotNull EventDispatcher<AgentLifeCycleListener> events) { LOG.info("VSphere plugin initializing..."); myAgentConfiguration = agentConfiguration; myVMWareRPCToolPath = getToolPath(myAgentConfiguration); if (myVMWareRPCToolPath == null) { LOG.info("Unable to locate " + VMWARE_RPCTOOL_NAME + ". Looks like not a VMWare VM or VWWare tools are not installed"); return; } else { LOG.info("Detected vmware-tools or open-vm-tools. Found required vmware-rpctool at " + myVMWareRPCToolPath + ". " + "Will attempt to authorize agent as VMWare cloud agent. "); } events.addListener(new AgentLifeCycleAdapter(){ @Override public void afterAgentConfigurationLoaded(@NotNull final BuildAgent agent) { final String serverUrl = getPropertyValue(SERVER_URL); if (StringUtil.isEmpty(serverUrl)){ LOG.info("Unable to read property " + SERVER_URL + ". VMWare integration is disabled"); return; } else { LOG.info("Server URL: " + serverUrl); } final String instanceName = getPropertyValue(INSTANCE_NAME); if (StringUtil.isEmpty(instanceName)){ LOG.info("Unable to read property " + INSTANCE_NAME + ". VMWare integration is disabled"); return; } else { LOG.info("Instance name: " + instanceName); } myAgentConfiguration.setName(instanceName); myAgentConfiguration.setServerUrl(serverUrl); myAgentConfiguration.addConfigurationParameter(INSTANCE_NAME, instanceName); String imageName = getPropertyValue(IMAGE_NAME); if (!StringUtil.isEmpty(imageName)){ LOG.info("Image name: " + imageName); myAgentConfiguration.addConfigurationParameter(IMAGE_NAME, imageName); } String userData = getPropertyValue(USER_DATA); if (!StringUtil.isEmpty(userData)){ LOG.debug("UserData: " + userData); final CloudInstanceUserData cloudUserData = CloudInstanceUserData.deserialize(userData); if (cloudUserData != null) { final Map<String, String> customParameters = cloudUserData.getCustomAgentConfigurationParameters(); for (Map.Entry<String, String> entry : customParameters.entrySet()) { myAgentConfiguration.addConfigurationParameter(entry.getKey(), entry.getValue()); } } } } }); }