From: Simon Brandhof Date: Tue, 9 Jan 2018 09:51:32 +0000 (+0100) Subject: Drop deprecated class org.sonar.api.utils.Semaphores X-Git-Tag: 7.0-RC1~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a1e5594f2aace43f6c8dba7a0612a4c9e80f460e;p=sonarqube.git Drop deprecated class org.sonar.api.utils.Semaphores --- diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/SemaphoresImpl.java b/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/SemaphoresImpl.java deleted file mode 100644 index 12f92e20992..00000000000 --- a/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/SemaphoresImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.db.semaphore; - -import org.sonar.api.utils.Semaphores; - -public class SemaphoresImpl implements Semaphores { - - @Override - public Semaphore acquire(String name, int maxAgeInSeconds, int updatePeriodInSeconds) { - throw fail(); - } - - @Override - public Semaphore acquire(String name) { - throw fail(); - } - - @Override - public void release(String name) { - throw fail(); - } - - private static RuntimeException fail() { - throw new UnsupportedOperationException("Semaphores are not supported since 5.2 and the drop of database connection from analyzer"); - } -} diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/package-info.java b/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/package-info.java deleted file mode 100644 index 3c8c9bb0bda..00000000000 --- a/server/sonar-db-core/src/main/java/org/sonar/db/semaphore/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.db.semaphore; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/semaphore/SemaphoresImplTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/semaphore/SemaphoresImplTest.java deleted file mode 100644 index e591e51fdc6..00000000000 --- a/server/sonar-db-core/src/test/java/org/sonar/db/semaphore/SemaphoresImplTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.db.semaphore; - -import org.junit.Test; - -public class SemaphoresImplTest { - - @Test(expected = UnsupportedOperationException.class) - public void acquire_is_unsupported() { - new SemaphoresImpl().acquire("foo"); - } - - @Test(expected = UnsupportedOperationException.class) - public void acquire_with_timeout_is_unsupported() { - new SemaphoresImpl().acquire("foo", 1, 2); - } - - @Test(expected = UnsupportedOperationException.class) - public void release_is_unsupported() { - new SemaphoresImpl().release("foo"); - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index 6a124ecd56a..d361e65f216 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -38,7 +38,6 @@ import org.sonar.db.DatabaseChecker; import org.sonar.db.DbClient; import org.sonar.db.DefaultDatabase; import org.sonar.db.purge.PurgeProfiler; -import org.sonar.db.semaphore.SemaphoresImpl; import org.sonar.process.NetworkUtilsImpl; import org.sonar.process.logging.LogbackHelper; import org.sonar.server.app.ProcessCommandWrapperImpl; @@ -98,7 +97,6 @@ public class PlatformLevel1 extends PlatformLevel { org.sonar.core.persistence.MyBatis.class, PurgeProfiler.class, ServerFileSystemImpl.class, - SemaphoresImpl.class, TempFolderCleaner.class, new TempFolderProvider(), System2.INSTANCE, diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Semaphores.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Semaphores.java deleted file mode 100644 index c3afb1686a5..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Semaphores.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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.api.utils; - -import java.util.Date; -import javax.annotation.Nullable; -import org.sonar.api.server.ServerSide; - -/** - * A semaphore shared among all the processes that can connect to the central database. - * - * @since 3.4 - * @deprecated in 5.2 as analyzer does not connect to database anymore - */ -@ServerSide -@Deprecated -public interface Semaphores { - - /** - * Try to acquire a semaphore for a given duration. - * The semaphore is acquired if it's unlocked or if the max locking duration is reached. - * When the lock is acquired there will be a periodic ping of the - * server to update the semaphore and avoid it to be considered as - * outdated. - * - * @param name the key of the semaphore - * @param maxAgeInSeconds the max duration in seconds the semaphore will be considered unlocked if - * it was not updated. The value zero forces the semaphore to be acquired, whatever its status. - * @param updatePeriodInSeconds the period in seconds the semaphore will be updated. - * @return the semaphore, whatever its status (locked or unlocked). Can't be null. - */ - Semaphore acquire(String name, int maxAgeInSeconds, int updatePeriodInSeconds); - - /** - * Try to acquire a semaphore. - * The semaphore will be acquired only if there's no existing lock. - * - * @param name the key of the semaphore - * @return the semaphore, whatever its status (locked or unlocked). Can't be null. - */ - Semaphore acquire(String name); - - /** - * Release the lock on a semaphore by its name. Does nothing if the lock is already released. - * - * @param name the key of the semaphore - */ - void release(String name); - - class Semaphore { - - private String name; - private boolean locked; - private Date lockedAt; - private Date createdAt; - private Date updatedAt; - private Long durationSinceLocked; - - public String getName() { - return name; - } - - public Semaphore setName(String name) { - this.name = name; - return this; - } - - public boolean isLocked() { - return locked; - } - - public Semaphore setLocked(boolean locked) { - this.locked = locked; - return this; - } - - public Date getLockedAt() { - return lockedAt; - } - - public Semaphore setLockedAt(@Nullable Date lockedAt) { - this.lockedAt = lockedAt; - return this; - } - - public Date getCreatedAt() { - return createdAt; - } - - public Semaphore setCreatedAt(@Nullable Date createdAt) { - this.createdAt = createdAt; - return this; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public Semaphore setUpdatedAt(@Nullable Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public Long getDurationSinceLocked() { - return durationSinceLocked; - } - - public Semaphore setDurationSinceLocked(Long durationSinceLocked) { - this.durationSinceLocked = durationSinceLocked; - return this; - } - } - -}