Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-8985 add unique identifier to CeWorker
- Loading branch information
Showing
11 changed files
with
265 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.ce.taskprocessor; | |||
|
|||
import java.util.Set; | |||
|
|||
/** | |||
* A factory that will create the CeWorkerFactory with an UUID | |||
*/ | |||
public interface CeWorkerFactory { | |||
/** | |||
* Create a new CeWorker object. | |||
* Each {@link CeWorker} returned by this method will have a different UUID from the others and all of these UUIDS will be returned by {@link #getWorkerUUIDs()}. | |||
* | |||
* @return the CeWorker | |||
*/ | |||
CeWorker create(); | |||
/** | |||
* @return the UUIDs of each {@link CeWorker} object returned by {@link #create}. | |||
*/ | |||
Set<String> getWorkerUUIDs(); | |||
} |
56 changes: 56 additions & 0 deletions
56
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
package org.sonar.ce.taskprocessor; | |||
|
|||
import java.util.HashSet; | |||
import java.util.Set; | |||
import org.sonar.ce.log.CeLogging; | |||
import org.sonar.ce.queue.InternalCeQueue; | |||
import org.sonar.core.util.UuidFactory; | |||
|
|||
import static com.google.common.collect.ImmutableSet.copyOf; | |||
|
|||
public class CeWorkerFactoryImpl implements CeWorkerFactory { | |||
private final UuidFactory uuidFactory; | |||
private final Set<String> ceWorkerUUIDs = new HashSet<>(); | |||
private final InternalCeQueue queue; | |||
private final CeLogging ceLogging; | |||
private final CeTaskProcessorRepository taskProcessorRepository; | |||
|
|||
public CeWorkerFactoryImpl(InternalCeQueue queue, CeLogging ceLogging, CeTaskProcessorRepository taskProcessorRepository, UuidFactory uuidFactory) { | |||
this.queue = queue; | |||
this.ceLogging = ceLogging; | |||
this.taskProcessorRepository = taskProcessorRepository; | |||
this.uuidFactory= uuidFactory; | |||
} | |||
|
|||
@Override | |||
public CeWorker create() { | |||
String uuid = uuidFactory.create(); | |||
ceWorkerUUIDs.add(uuid); | |||
return new CeWorkerImpl(queue, ceLogging, taskProcessorRepository, uuid); | |||
} | |||
|
|||
@Override | |||
public Set<String> getWorkerUUIDs() { | |||
return copyOf(ceWorkerUUIDs); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.