repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
tmurakami/dexopener
dexopener/src/main/java/com/github/tmurakami/dexopener/Loggers.java
// Path: dexopener/src/main/java/com/github/tmurakami/dexopener/Constants.java // static final String MY_PACKAGE = "com.github.tmurakami.dexopener";
import java.util.logging.Logger; import static com.github.tmurakami.dexopener.Constants.MY_PACKAGE;
/* * Copyright 2016 Tsuyoshi Murakami * * 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.github.tmurakami.dexopener; final class Loggers { private Loggers() { throw new AssertionError("Do not instantiate"); } static Logger get() {
// Path: dexopener/src/main/java/com/github/tmurakami/dexopener/Constants.java // static final String MY_PACKAGE = "com.github.tmurakami.dexopener"; // Path: dexopener/src/main/java/com/github/tmurakami/dexopener/Loggers.java import java.util.logging.Logger; import static com.github.tmurakami.dexopener.Constants.MY_PACKAGE; /* * Copyright 2016 Tsuyoshi Murakami * * 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.github.tmurakami.dexopener; final class Loggers { private Loggers() { throw new AssertionError("Do not instantiate"); } static Logger get() {
return Logger.getLogger(MY_PACKAGE);
tmurakami/dexopener
dexopener/src/test/java/com/github/tmurakami/dexopener/ClassPathTest.java
// Path: dexopener/src/test/java/test/MyClass.java // public class MyClass { // }
import android.content.Context; import android.content.pm.ApplicationInfo; import com.github.tmurakami.dexopener.repackaged.com.google.common.base.Predicate; import org.jf.dexlib2.Opcodes; import org.jf.dexlib2.immutable.ImmutableClassDef; import org.jf.dexlib2.immutable.ImmutableDexFile; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.RunnableFuture; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import test.MyClass; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.mockito.AdditionalAnswers.answer; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.withSettings;
@SuppressWarnings("deprecation") @Test public void should_get_the_Class_with_the_given_name() throws IOException { given(classNameFilter.apply(anyString())).willReturn(true); ApplicationInfo ai = new ApplicationInfo(); given(context.getApplicationInfo()).willReturn(ai); ai.dataDir = folder.newFolder().getCanonicalPath(); int classCount = 101; // MAX_CLASSES_PER_DEX_FILE + 1 List<String> classNames = new ArrayList<>(classCount); for (int i = 0; i < classCount; i++) { classNames.add("foo.Bar" + i); } Set<ImmutableClassDef> classes = new HashSet<>(); for (String className : classNames) { classes.add(new ImmutableClassDef('L' + className.replace('.', '/') + ';', 0, null, null, null, null, null, null)); } ImmutableDexFile dexFile = new ImmutableDexFile(Opcodes.getDefault(), classes); File zip = folder.newFile(); try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip))) { out.putNextEntry(new ZipEntry("classes.dex")); out.write(DexPoolUtils.toBytecode(dexFile)); } ai.sourceDir = zip.getCanonicalPath(); ClassLoader loader = new ClassLoader() { }; given(dexFileLoader.loadDex(anyString(), anyString())) .will(answer((src, out) -> { dalvik.system.DexFile file = mock(dalvik.system.DexFile.class, withSettings().stubOnly());
// Path: dexopener/src/test/java/test/MyClass.java // public class MyClass { // } // Path: dexopener/src/test/java/com/github/tmurakami/dexopener/ClassPathTest.java import android.content.Context; import android.content.pm.ApplicationInfo; import com.github.tmurakami.dexopener.repackaged.com.google.common.base.Predicate; import org.jf.dexlib2.Opcodes; import org.jf.dexlib2.immutable.ImmutableClassDef; import org.jf.dexlib2.immutable.ImmutableDexFile; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.RunnableFuture; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import test.MyClass; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.mockito.AdditionalAnswers.answer; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.withSettings; @SuppressWarnings("deprecation") @Test public void should_get_the_Class_with_the_given_name() throws IOException { given(classNameFilter.apply(anyString())).willReturn(true); ApplicationInfo ai = new ApplicationInfo(); given(context.getApplicationInfo()).willReturn(ai); ai.dataDir = folder.newFolder().getCanonicalPath(); int classCount = 101; // MAX_CLASSES_PER_DEX_FILE + 1 List<String> classNames = new ArrayList<>(classCount); for (int i = 0; i < classCount; i++) { classNames.add("foo.Bar" + i); } Set<ImmutableClassDef> classes = new HashSet<>(); for (String className : classNames) { classes.add(new ImmutableClassDef('L' + className.replace('.', '/') + ';', 0, null, null, null, null, null, null)); } ImmutableDexFile dexFile = new ImmutableDexFile(Opcodes.getDefault(), classes); File zip = folder.newFile(); try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip))) { out.putNextEntry(new ZipEntry("classes.dex")); out.write(DexPoolUtils.toBytecode(dexFile)); } ai.sourceDir = zip.getCanonicalPath(); ClassLoader loader = new ClassLoader() { }; given(dexFileLoader.loadDex(anyString(), anyString())) .will(answer((src, out) -> { dalvik.system.DexFile file = mock(dalvik.system.DexFile.class, withSettings().stubOnly());
given(file.loadClass(anyString(), eq(loader))).willReturn(MyClass.class);
tmurakami/dexopener
dexopener/src/androidTest/java/test/com/github/tmurakami/dexopener/MyAndroidJUnitRunner.java
// Path: dexopener/src/main/java/com/github/tmurakami/dexopener/DexOpener.java // public final class DexOpener { // // private static final String[] REFUSED_PACKAGES = { // MY_PACKAGE_PREFIX, // // Android // "android.", // "androidx.", // "com.android.", // "com.google.android.", // "com.sun.", // "dalvik.", // "java.", // "javax.", // "libcore.", // "org.apache.commons.logging.", // "org.apache.harmony.", // "org.apache.http.", // "org.ccil.cowan.tagsoup.", // "org.json.", // "org.kxml2.io.", // "org.w3c.dom.", // "org.xml.sax.", // "org.xmlpull.v1.", // "sun.", // // JUnit 4 // "junit.", // "org.hamcrest.", // "org.junit.", // }; // // private static final Executor EXECUTOR; // // static { // final AtomicInteger count = new AtomicInteger(); // int availableProcessors = Runtime.getRuntime().availableProcessors(); // int nThreads = Math.max(1, Math.min(availableProcessors, 4)); // 1 to 4 // EXECUTOR = Executors.newFixedThreadPool( // nThreads, r -> new Thread(r, "DexOpener #" + count.incrementAndGet())); // } // // private DexOpener() { // throw new AssertionError("Do not instantiate"); // } // // /** // * Provides the ability to mock your final classes. // * // * @param instrumentation the {@link Instrumentation} instance of your AndroidJUnitRunner // * subclass // * @throws IllegalStateException if this method is called twice or is called in an // * inappropriate location // * @throws UnsupportedOperationException if the given {@link Instrumentation} instance belongs // * to a special package such as 'android' // * @apiNote This method must be called first on the // * {@link Instrumentation#newApplication(ClassLoader, String, Context) // * newApplication(ClassLoader, String, Context)} method overridden in your AndroidJUnitRunner // * subclass. // */ // public static void install(@NonNull Instrumentation instrumentation) { // Context context = instrumentation.getTargetContext(); // if (context == null) { // String instrumentationName = instrumentation.getClass().getSimpleName(); // throw new IllegalStateException( // "The " + instrumentationName + " instance has not yet been initialized"); // } // Context app = context.getApplicationContext(); // if (app != null) { // throw new IllegalStateException( // "The " + app.getClass().getSimpleName() + " instance has already been created"); // } // ClassLoader loader = context.getClassLoader(); // for (ClassLoader l = loader; l != null; l = l.getParent()) { // if (l instanceof ClassInjector) { // throw new IllegalStateException("Already installed"); // } // } // DexNameFilter dexNameFilter = createDexNameFilter(instrumentation.getClass()); // ClassPath classPath = new ClassPath(context, dexNameFilter, new DexFileLoader(), EXECUTOR); // ClassLoaderHelper.setParent(loader, new ClassInjector(loader, classPath)); // } // // private static DexNameFilter createDexNameFilter(Class<?> rootClass) { // String className = rootClass.getName(); // int lastDotPos = className.lastIndexOf('.'); // String packageName = lastDotPos == -1 ? null : className.substring(0, lastDotPos); // if (isSupportedPackage(packageName)) { // Logger logger = Loggers.get(); // if (logger.isLoggable(Level.FINEST)) { // logger.finest("The final classes under " + packageName + " will be opened"); // } // return new DexNameFilter(packageName, rootClass); // } // throw new UnsupportedOperationException( // "Install to an Instrumentation instance the package of which is " + packageName); // } // // private static boolean isSupportedPackage(String packageName) { // if (packageName == null || packageName.indexOf('.') == -1) { // return false; // } // for (String pkg : REFUSED_PACKAGES) { // if (packageName.startsWith(pkg)) { // return false; // } // } // return true; // } // // }
import android.app.Application; import android.content.Context; import androidx.test.runner.AndroidJUnitRunner; import com.github.tmurakami.dexopener.DexOpener;
/* * Copyright 2016 Tsuyoshi Murakami * * 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 test.com.github.tmurakami.dexopener; public class MyAndroidJUnitRunner extends AndroidJUnitRunner { @Override public Application newApplication(ClassLoader cl, String className, Context context) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
// Path: dexopener/src/main/java/com/github/tmurakami/dexopener/DexOpener.java // public final class DexOpener { // // private static final String[] REFUSED_PACKAGES = { // MY_PACKAGE_PREFIX, // // Android // "android.", // "androidx.", // "com.android.", // "com.google.android.", // "com.sun.", // "dalvik.", // "java.", // "javax.", // "libcore.", // "org.apache.commons.logging.", // "org.apache.harmony.", // "org.apache.http.", // "org.ccil.cowan.tagsoup.", // "org.json.", // "org.kxml2.io.", // "org.w3c.dom.", // "org.xml.sax.", // "org.xmlpull.v1.", // "sun.", // // JUnit 4 // "junit.", // "org.hamcrest.", // "org.junit.", // }; // // private static final Executor EXECUTOR; // // static { // final AtomicInteger count = new AtomicInteger(); // int availableProcessors = Runtime.getRuntime().availableProcessors(); // int nThreads = Math.max(1, Math.min(availableProcessors, 4)); // 1 to 4 // EXECUTOR = Executors.newFixedThreadPool( // nThreads, r -> new Thread(r, "DexOpener #" + count.incrementAndGet())); // } // // private DexOpener() { // throw new AssertionError("Do not instantiate"); // } // // /** // * Provides the ability to mock your final classes. // * // * @param instrumentation the {@link Instrumentation} instance of your AndroidJUnitRunner // * subclass // * @throws IllegalStateException if this method is called twice or is called in an // * inappropriate location // * @throws UnsupportedOperationException if the given {@link Instrumentation} instance belongs // * to a special package such as 'android' // * @apiNote This method must be called first on the // * {@link Instrumentation#newApplication(ClassLoader, String, Context) // * newApplication(ClassLoader, String, Context)} method overridden in your AndroidJUnitRunner // * subclass. // */ // public static void install(@NonNull Instrumentation instrumentation) { // Context context = instrumentation.getTargetContext(); // if (context == null) { // String instrumentationName = instrumentation.getClass().getSimpleName(); // throw new IllegalStateException( // "The " + instrumentationName + " instance has not yet been initialized"); // } // Context app = context.getApplicationContext(); // if (app != null) { // throw new IllegalStateException( // "The " + app.getClass().getSimpleName() + " instance has already been created"); // } // ClassLoader loader = context.getClassLoader(); // for (ClassLoader l = loader; l != null; l = l.getParent()) { // if (l instanceof ClassInjector) { // throw new IllegalStateException("Already installed"); // } // } // DexNameFilter dexNameFilter = createDexNameFilter(instrumentation.getClass()); // ClassPath classPath = new ClassPath(context, dexNameFilter, new DexFileLoader(), EXECUTOR); // ClassLoaderHelper.setParent(loader, new ClassInjector(loader, classPath)); // } // // private static DexNameFilter createDexNameFilter(Class<?> rootClass) { // String className = rootClass.getName(); // int lastDotPos = className.lastIndexOf('.'); // String packageName = lastDotPos == -1 ? null : className.substring(0, lastDotPos); // if (isSupportedPackage(packageName)) { // Logger logger = Loggers.get(); // if (logger.isLoggable(Level.FINEST)) { // logger.finest("The final classes under " + packageName + " will be opened"); // } // return new DexNameFilter(packageName, rootClass); // } // throw new UnsupportedOperationException( // "Install to an Instrumentation instance the package of which is " + packageName); // } // // private static boolean isSupportedPackage(String packageName) { // if (packageName == null || packageName.indexOf('.') == -1) { // return false; // } // for (String pkg : REFUSED_PACKAGES) { // if (packageName.startsWith(pkg)) { // return false; // } // } // return true; // } // // } // Path: dexopener/src/androidTest/java/test/com/github/tmurakami/dexopener/MyAndroidJUnitRunner.java import android.app.Application; import android.content.Context; import androidx.test.runner.AndroidJUnitRunner; import com.github.tmurakami.dexopener.DexOpener; /* * Copyright 2016 Tsuyoshi Murakami * * 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 test.com.github.tmurakami.dexopener; public class MyAndroidJUnitRunner extends AndroidJUnitRunner { @Override public Application newApplication(ClassLoader cl, String className, Context context) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
DexOpener.install(this);
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/configuration/TwitchTest.java
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // }
import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.Assertions.assertThat;
package com.deswaef.twitch.configuration; public class TwitchTest { public static final String BASE_URL = "https://api.twitch.tv/kraken"; public static final String CLIENT_ID = "clientId"; public static final String CLIENT_SECRET = "clientSecret"; public static final String REDIRECT_URI = "redirectURI"; public static final String GRANT_TYPE = "authorization_code"; private Twitch twitch; @Before public void init(){ twitch = Twitch.newTwitchInstance(BASE_URL, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI); } @Test public void newHasValidAccessTokenRequestTemplate(){
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // Path: src/test/java/com/deswaef/twitch/configuration/TwitchTest.java import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.Assertions.assertThat; package com.deswaef.twitch.configuration; public class TwitchTest { public static final String BASE_URL = "https://api.twitch.tv/kraken"; public static final String CLIENT_ID = "clientId"; public static final String CLIENT_SECRET = "clientSecret"; public static final String REDIRECT_URI = "redirectURI"; public static final String GRANT_TYPE = "authorization_code"; private Twitch twitch; @Before public void init(){ twitch = Twitch.newTwitchInstance(BASE_URL, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI); } @Test public void newHasValidAccessTokenRequestTemplate(){
AccessTokenRequest requestTemplate = (AccessTokenRequest) new Mirror().on(twitch.accessTokens()).get().field("requestTemplate");
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/videos/VideoResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // }
import com.deswaef.twitch.api.videos.domain.Video; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import org.omg.PortableInterceptor.NON_EXISTENT; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat;
private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); videoResource = new VideoResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { assertThat(new Mirror().on(videoResource).get().field("videoService")).isNotNull(); } @Test public void videosAndNotEmpty() { assertThat(videoResource.videos(CHANNEL_WITH_VIDEOS)).isNotEmpty(); } @Test public void validateVideoProperties(){ videoResource.videos(CHANNEL_WITH_VIDEOS) .stream() .forEach(this::validateVideo); } @Test public void existingVideoHasCorrectFields(){
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // Path: src/test/java/com/deswaef/twitch/api/videos/VideoResourceTest.java import com.deswaef.twitch.api.videos.domain.Video; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import org.omg.PortableInterceptor.NON_EXISTENT; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); videoResource = new VideoResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { assertThat(new Mirror().on(videoResource).get().field("videoService")).isNotNull(); } @Test public void videosAndNotEmpty() { assertThat(videoResource.videos(CHANNEL_WITH_VIDEOS)).isNotEmpty(); } @Test public void validateVideoProperties(){ videoResource.videos(CHANNEL_WITH_VIDEOS) .stream() .forEach(this::validateVideo); } @Test public void existingVideoHasCorrectFields(){
Optional<Video> video = videoResource.video(EXISTING_VIDEO_ID);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/games/GamesResource.java
// Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResultWrapper.java // public class GameTopResultWrapper { // // @SerializedName("_total") // private Long total; // // public Long getTotal() { // return total; // } // // public void setTotal(Long total) { // this.total = total; // } // // @SerializedName("top") // private List<GameTopResult> top; // // public List<GameTopResult> getTop() { // return top; // } // // public void setTop(List<GameTopResult> top) { // this.top = top; // } // }
import com.deswaef.twitch.api.games.domain.GameTopResultWrapper; import retrofit.RestAdapter; import java.util.Optional;
package com.deswaef.twitch.api.games; /** * User: Quinten * Date: 24-9-2014 * Time: 12:35 * * @author Quinten De Swaef */ public class GamesResource { private GamesService gamesService;
// Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResultWrapper.java // public class GameTopResultWrapper { // // @SerializedName("_total") // private Long total; // // public Long getTotal() { // return total; // } // // public void setTotal(Long total) { // this.total = total; // } // // @SerializedName("top") // private List<GameTopResult> top; // // public List<GameTopResult> getTop() { // return top; // } // // public void setTop(List<GameTopResult> top) { // this.top = top; // } // } // Path: src/main/java/com/deswaef/twitch/api/games/GamesResource.java import com.deswaef.twitch.api.games.domain.GameTopResultWrapper; import retrofit.RestAdapter; import java.util.Optional; package com.deswaef.twitch.api.games; /** * User: Quinten * Date: 24-9-2014 * Time: 12:35 * * @author Quinten De Swaef */ public class GamesResource { private GamesService gamesService;
public Optional<GameTopResultWrapper> top() {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // }
import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.RestAdapter;
package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 16-9-2014 * Time: 14:24 * * @author Quinten De Swaef */ public class AccessTokenResource { private AccessTokenService accessTokenService;
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // } // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.RestAdapter; package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 16-9-2014 * Time: 14:24 * * @author Quinten De Swaef */ public class AccessTokenResource { private AccessTokenService accessTokenService;
private AccessTokenRequest requestTemplate;
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // }
import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.RestAdapter;
package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 16-9-2014 * Time: 14:24 * * @author Quinten De Swaef */ public class AccessTokenResource { private AccessTokenService accessTokenService; private AccessTokenRequest requestTemplate; public AccessTokenResource() { super(); requestTemplate = new AccessTokenRequest(); }
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // } // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.RestAdapter; package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 16-9-2014 * Time: 14:24 * * @author Quinten De Swaef */ public class AccessTokenResource { private AccessTokenService accessTokenService; private AccessTokenRequest requestTemplate; public AccessTokenResource() { super(); requestTemplate = new AccessTokenRequest(); }
public AccessTokenResponse requestToken(String accessCode) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // }
import com.deswaef.twitch.api.channels.domain.TwitchChannel; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.Optional;
package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 23-8-2014 * Time: 01:04 * * @author Quinten De Swaef */ public class ChannelResource { private ChannelService channelService;
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // } // Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java import com.deswaef.twitch.api.channels.domain.TwitchChannel; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.Optional; package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 23-8-2014 * Time: 01:04 * * @author Quinten De Swaef */ public class ChannelResource { private ChannelService channelService;
public Optional<TwitchChannel> channel(String channelName) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // }
import com.deswaef.twitch.api.channels.domain.TwitchChannel; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.Optional;
package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 23-8-2014 * Time: 01:04 * * @author Quinten De Swaef */ public class ChannelResource { private ChannelService channelService; public Optional<TwitchChannel> channel(String channelName) {
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // } // Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java import com.deswaef.twitch.api.channels.domain.TwitchChannel; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.Optional; package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 23-8-2014 * Time: 01:04 * * @author Quinten De Swaef */ public class ChannelResource { private ChannelService channelService; public Optional<TwitchChannel> channel(String channelName) {
Assert.notNull(channelName, "please enter a channelname");
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java
// Path: src/main/java/com/deswaef/twitch/exception/States.java // public static void state(boolean state, String errorMessage) { // if (!state) { // throw new IllegalStateException(errorMessage); // } // }
import static com.deswaef.twitch.exception.States.state;
return new AuthorizationURLBuilder(); } public AuthorizationURLBuilder baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } public AuthorizationURLBuilder clientId(String clientId) { this.clientId = clientId; return this; } public AuthorizationURLBuilder redirectURI(String redirectURI) { this.redirectURI = redirectURI; return this; } public AuthorizationURLBuilder withScope(String scope) { if(this.scopes == null || scope.isEmpty()) { this.scopes = scope; } else { this.scopes += String.format("+%s", scope); } return this; } @Override public String toString() {
// Path: src/main/java/com/deswaef/twitch/exception/States.java // public static void state(boolean state, String errorMessage) { // if (!state) { // throw new IllegalStateException(errorMessage); // } // } // Path: src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java import static com.deswaef.twitch.exception.States.state; return new AuthorizationURLBuilder(); } public AuthorizationURLBuilder baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } public AuthorizationURLBuilder clientId(String clientId) { this.clientId = clientId; return this; } public AuthorizationURLBuilder redirectURI(String redirectURI) { this.redirectURI = redirectURI; return this; } public AuthorizationURLBuilder withScope(String scope) { if(this.scopes == null || scope.isEmpty()) { this.scopes = scope; } else { this.scopes += String.format("+%s", scope); } return this; } @Override public String toString() {
state(notBlank(baseUrl), "Cannot build authentication url, please set the baseURL first");
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/games/GamesService.java
// Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResultWrapper.java // public class GameTopResultWrapper { // // @SerializedName("_total") // private Long total; // // public Long getTotal() { // return total; // } // // public void setTotal(Long total) { // this.total = total; // } // // @SerializedName("top") // private List<GameTopResult> top; // // public List<GameTopResult> getTop() { // return top; // } // // public void setTop(List<GameTopResult> top) { // this.top = top; // } // }
import com.deswaef.twitch.api.games.domain.GameTopResultWrapper; import retrofit.http.GET;
package com.deswaef.twitch.api.games; /** * User: Quinten * Date: 5-7-2015 * Time: 00:33 * * @author Quinten De Swaef */ public interface GamesService { @GET("/games/top")
// Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResultWrapper.java // public class GameTopResultWrapper { // // @SerializedName("_total") // private Long total; // // public Long getTotal() { // return total; // } // // public void setTotal(Long total) { // this.total = total; // } // // @SerializedName("top") // private List<GameTopResult> top; // // public List<GameTopResult> getTop() { // return top; // } // // public void setTop(List<GameTopResult> top) { // this.top = top; // } // } // Path: src/main/java/com/deswaef/twitch/api/games/GamesService.java import com.deswaef.twitch.api.games.domain.GameTopResultWrapper; import retrofit.http.GET; package com.deswaef.twitch.api.games; /** * User: Quinten * Date: 5-7-2015 * Time: 00:33 * * @author Quinten De Swaef */ public interface GamesService { @GET("/games/top")
public GameTopResultWrapper top();
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/ingests/IngestsResource.java
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // } // // Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // }
import com.deswaef.twitch.api.ingests.domain.Ingest; import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List;
package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 28-9-2014 * Time: 23:46 * * @author Quinten De Swaef */ public class IngestsResource { private IngestsService ingestsService;
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // } // // Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // } // Path: src/main/java/com/deswaef/twitch/api/ingests/IngestsResource.java import com.deswaef.twitch.api.ingests.domain.Ingest; import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 28-9-2014 * Time: 23:46 * * @author Quinten De Swaef */ public class IngestsResource { private IngestsService ingestsService;
public List<Ingest> ingests() {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/ingests/IngestsResource.java
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // } // // Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // }
import com.deswaef.twitch.api.ingests.domain.Ingest; import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List;
package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 28-9-2014 * Time: 23:46 * * @author Quinten De Swaef */ public class IngestsResource { private IngestsService ingestsService; public List<Ingest> ingests() { try {
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // } // // Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // } // Path: src/main/java/com/deswaef/twitch/api/ingests/IngestsResource.java import com.deswaef.twitch.api.ingests.domain.Ingest; import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 28-9-2014 * Time: 23:46 * * @author Quinten De Swaef */ public class IngestsResource { private IngestsService ingestsService; public List<Ingest> ingests() { try {
IngestResult ingests = ingestsService.ingests();
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/videos/VideoResource.java
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // }
import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 27-9-2014 * Time: 01:41 * * @author Quinten De Swaef */ public class VideoResource { private VideoService videoService;
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // } // Path: src/main/java/com/deswaef/twitch/api/videos/VideoResource.java import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 27-9-2014 * Time: 01:41 * * @author Quinten De Swaef */ public class VideoResource { private VideoService videoService;
public Optional<Video> video(String id) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/videos/VideoResource.java
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // }
import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 27-9-2014 * Time: 01:41 * * @author Quinten De Swaef */ public class VideoResource { private VideoService videoService; public Optional<Video> video(String id) { try { return Optional.ofNullable(videoService.video(id)); } catch (Exception ex) { return Optional.empty(); } } public List<Video> videos(String channel) {
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // } // Path: src/main/java/com/deswaef/twitch/api/videos/VideoResource.java import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 27-9-2014 * Time: 01:41 * * @author Quinten De Swaef */ public class VideoResource { private VideoService videoService; public Optional<Video> video(String id) { try { return Optional.ofNullable(videoService.video(id)); } catch (Exception ex) { return Optional.empty(); } } public List<Video> videos(String channel) {
Optional<VideosResponse> responseWrapper = null;
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/oauth/AccessTokenService.java
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // }
import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.http.Body; import retrofit.http.POST;
package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 5-7-2015 * Time: 00:40 * * @author Quinten De Swaef */ public interface AccessTokenService { @POST("/oauth2/token")
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // } // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenService.java import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.http.Body; import retrofit.http.POST; package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 5-7-2015 * Time: 00:40 * * @author Quinten De Swaef */ public interface AccessTokenService { @POST("/oauth2/token")
AccessTokenResponse requestToken(@Body AccessTokenRequest accessTokenRequest);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/oauth/AccessTokenService.java
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // }
import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.http.Body; import retrofit.http.POST;
package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 5-7-2015 * Time: 00:40 * * @author Quinten De Swaef */ public interface AccessTokenService { @POST("/oauth2/token")
// Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenRequest.java // public class AccessTokenRequest { // // private String client_id; // private String client_secret; // private String grant_type = "authorization_code"; // private String redirect_uri; // private String code; // // public AccessTokenRequest copy(String code) { // return new AccessTokenRequest() // .setClient_secret(this.client_secret) // .setRedirect_uri(this.getRedirect_uri()) // .setClient_id(this.getClient_id()) // .setGrant_type(this.getGrant_type()) // .setCode(code); // } // // public String getClient_id() { // return client_id; // } // // public AccessTokenRequest setClient_id(String client_id) { // this.client_id = client_id; // return this; // } // // public String getClient_secret() { // return client_secret; // } // // public AccessTokenRequest setClient_secret(String client_secret) { // this.client_secret = client_secret; // return this; // } // // public String getGrant_type() { // return grant_type; // } // // public AccessTokenRequest setGrant_type(String grant_type) { // this.grant_type = grant_type; // return this; // } // // public String getRedirect_uri() { // return redirect_uri; // } // // public AccessTokenRequest setRedirect_uri(String redirect_uri) { // this.redirect_uri = redirect_uri; // return this; // } // // public String getCode() { // return code; // } // // public AccessTokenRequest setCode(String code) { // this.code = code; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/domain/AccessTokenResponse.java // public class AccessTokenResponse { // // private AccessTokenResponseEnum status = AccessTokenResponseEnum.OK; // // public static AccessTokenResponse invalid_code() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.INVALID_CODE); // } // // public static AccessTokenResponse forbidden() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.FORBIDDEN); // } // // public static AccessTokenResponse unknown_issue() { // return new AccessTokenResponse() // .setStatus(AccessTokenResponseEnum.UNKNOWN_ISSUE); // } // // // // private String access_token; // private String refresh_token; // private String[] scope; // // public String getAccess_token() { // return access_token; // } // // public AccessTokenResponse setAccess_token(String access_token) { // this.access_token = access_token; // return this; // } // // public String getRefresh_token() { // return refresh_token; // } // // public AccessTokenResponse setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // return this; // } // // public AccessTokenResponseEnum getStatus() { // return status; // } // // public AccessTokenResponse setStatus(AccessTokenResponseEnum status) { // this.status = status; // return this; // } // // public String[] getScope() { // return scope; // } // // public AccessTokenResponse setScope(String[] scope) { // this.scope = scope; // return this; // } // } // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenService.java import com.deswaef.twitch.api.oauth.domain.AccessTokenRequest; import com.deswaef.twitch.api.oauth.domain.AccessTokenResponse; import retrofit.http.Body; import retrofit.http.POST; package com.deswaef.twitch.api.oauth; /** * User: Quinten * Date: 5-7-2015 * Time: 00:40 * * @author Quinten De Swaef */ public interface AccessTokenService { @POST("/oauth2/token")
AccessTokenResponse requestToken(@Body AccessTokenRequest accessTokenRequest);
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/chat/ChatResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.when;
package com.deswaef.twitch.api.chat; public class ChatResourceTest { private ChatResource resource; private RestAdapter restAdapter; @Mock private ChatService chatService; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); resource = new ChatResource().url(restAdapter); } @Test public void getValidChatResource() {
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/test/java/com/deswaef/twitch/api/chat/ChatResourceTest.java import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.when; package com.deswaef.twitch.api.chat; public class ChatResourceTest { private ChatResource resource; private RestAdapter restAdapter; @Mock private ChatService chatService; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); resource = new ChatResource().url(restAdapter); } @Test public void getValidChatResource() {
Optional<ChatLinksInformation> streamingforanimals = resource.chatUser("streamingforanimals");
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/channels/ChannelResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // }
import com.deswaef.twitch.api.channels.domain.TwitchChannel; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import java.util.Optional; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat;
package com.deswaef.twitch.api.channels; public class ChannelResourceTest { public static final String BASE_URL = "BASE_URL"; private ChannelResource channelResource; private RestAdapter restAdapter; @Before public void init(){ restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); channelResource = new ChannelResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { assertThat(new Mirror().on(channelResource).get().field("channelService")).isNotNull(); } @Test public void verifyExistingChannel(){
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // } // Path: src/test/java/com/deswaef/twitch/api/channels/ChannelResourceTest.java import com.deswaef.twitch.api.channels.domain.TwitchChannel; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import java.util.Optional; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat; package com.deswaef.twitch.api.channels; public class ChannelResourceTest { public static final String BASE_URL = "BASE_URL"; private ChannelResource channelResource; private RestAdapter restAdapter; @Before public void init(){ restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); channelResource = new ChannelResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { assertThat(new Mirror().on(channelResource).get().field("channelService")).isNotNull(); } @Test public void verifyExistingChannel(){
Optional<TwitchChannel> streamingforanimals = channelResource.channel("streamingforanimals");
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/channels/ChannelService.java
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // }
import com.deswaef.twitch.api.channels.domain.TwitchChannel; import retrofit.http.GET; import retrofit.http.Path;
package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 5-7-2015 * Time: 01:03 * * @author Quinten De Swaef */ public interface ChannelService { @GET("/channels/{channel}")
// Path: src/main/java/com/deswaef/twitch/api/channels/domain/TwitchChannel.java // public class TwitchChannel { // @SerializedName("_id") // private Long id; // private String name; // private String status; // private String display_name; // private String game; // private int delay; // @SerializedName("created_at") // private Date createdAt; // @SerializedName("updated_at") // private Date updatedAt; // private String url; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getDisplay_name() { // return display_name; // } // // public void setDisplay_name(String display_name) { // this.display_name = display_name; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public int getDelay() { // return delay; // } // // public void setDelay(int delay) { // this.delay = delay; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // @Override // public String toString() { // return "TwitchChannel{" + // "id=" + id + // ", name='" + name + '\'' + // ", status='" + status + '\'' + // ", display_name='" + display_name + '\'' + // ", game='" + game + '\'' + // ", delay=" + delay + // ", createdAt=" + createdAt + // ", updatedAt=" + updatedAt + // ", url='" + url + '\'' + // '}'; // } // } // Path: src/main/java/com/deswaef/twitch/api/channels/ChannelService.java import com.deswaef.twitch.api.channels.domain.TwitchChannel; import retrofit.http.GET; import retrofit.http.Path; package com.deswaef.twitch.api.channels; /** * User: Quinten * Date: 5-7-2015 * Time: 01:03 * * @author Quinten De Swaef */ public interface ChannelService { @GET("/channels/{channel}")
TwitchChannel channel(@Path("channel") String channel);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/streams/StreamResource.java
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // }
import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // } // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */
public List<TwitchStream> streams() {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/streams/StreamResource.java
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // }
import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */ public List<TwitchStream> streams() { try { return Arrays.asList( streamService.streams() .getStreams()); } catch (Exception ex) { return new ArrayList<>(); } } /** * Returns an Optional of Streamcheck. * If the stream does not exist, the optional is empty. * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. * * @param stream String name of the stream * @return Optional of StreamCheck */
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // } // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */ public List<TwitchStream> streams() { try { return Arrays.asList( streamService.streams() .getStreams()); } catch (Exception ex) { return new ArrayList<>(); } } /** * Returns an Optional of Streamcheck. * If the stream does not exist, the optional is empty. * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. * * @param stream String name of the stream * @return Optional of StreamCheck */
public Optional<StreamCheck> stream(String stream) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/streams/StreamResource.java
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // }
import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */ public List<TwitchStream> streams() { try { return Arrays.asList( streamService.streams() .getStreams()); } catch (Exception ex) { return new ArrayList<>(); } } /** * Returns an Optional of Streamcheck. * If the stream does not exist, the optional is empty. * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. * * @param stream String name of the stream * @return Optional of StreamCheck */ public Optional<StreamCheck> stream(String stream) {
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/TwitchStream.java // public class TwitchStream { // // @SerializedName(value = "_id") // private Long id; // // private String game; // private Long viewers; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // @Override // public String toString() { // return "Stream{" + // "id=" + id + // ", game='" + game + '\'' + // ", viewers=" + viewers + // '}'; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/Assert.java // public class Assert { // public static void notNull(Object input, String errorMessage) { // if (input == null) { // throw new IllegalArgumentException(errorMessage); // } // } // } // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.TwitchStream; import com.deswaef.twitch.exception.Assert; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 22-8-2014 * Time: 20:47 * * @author Quinten De Swaef */ public class StreamResource { private StreamService streamService; /** * returns a list of the current top streams * * @return List of TwitchStream */ public List<TwitchStream> streams() { try { return Arrays.asList( streamService.streams() .getStreams()); } catch (Exception ex) { return new ArrayList<>(); } } /** * Returns an Optional of Streamcheck. * If the stream does not exist, the optional is empty. * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. * * @param stream String name of the stream * @return Optional of StreamCheck */ public Optional<StreamCheck> stream(String stream) {
Assert.notNull(stream, "url for stream must not be null");
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/oauth/AuthorizingUserConnectorTest.java
// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // }
import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.exception.UnAuthorizedException; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown;
package com.deswaef.twitch.api.oauth; public class AuthorizingUserConnectorTest { private UserResource connector; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); connector = new UserResource().url(restAdapter); } @Test public void testAndFaultyAccessToken() {
// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // } // Path: src/test/java/com/deswaef/twitch/api/oauth/AuthorizingUserConnectorTest.java import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.exception.UnAuthorizedException; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; package com.deswaef.twitch.api.oauth; public class AuthorizingUserConnectorTest { private UserResource connector; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); connector = new UserResource().url(restAdapter); } @Test public void testAndFaultyAccessToken() {
assertThrown(
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/oauth/AuthorizingUserConnectorTest.java
// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // }
import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.exception.UnAuthorizedException; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown;
package com.deswaef.twitch.api.oauth; public class AuthorizingUserConnectorTest { private UserResource connector; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); connector = new UserResource().url(restAdapter); } @Test public void testAndFaultyAccessToken() { assertThrown( () -> connector.getAuthenticatedUser("token")
// Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // } // Path: src/test/java/com/deswaef/twitch/api/oauth/AuthorizingUserConnectorTest.java import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.exception.UnAuthorizedException; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; package com.deswaef.twitch.api.oauth; public class AuthorizingUserConnectorTest { private UserResource connector; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); connector = new UserResource().url(restAdapter); } @Test public void testAndFaultyAccessToken() { assertThrown( () -> connector.getAuthenticatedUser("token")
).isInstanceOf(UnAuthorizedException.class);
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/ingests/IngestsResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // }
import com.deswaef.twitch.api.ingests.domain.Ingest; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat;
package com.deswaef.twitch.api.ingests; public class IngestsResourceTest { private IngestsResource ingestsResource; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); ingestsResource = new IngestsResource().url(restAdapter); } @Test public void ingestsReturnsAllIngests() { assertThat(ingestsResource.ingests()).isNotEmpty(); } @Test public void ingestsHaveValidFields() { ingestsResource .ingests() .stream() .forEach(this::validateIngest); }
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/Ingest.java // public class Ingest { // private String name; // private Integer availability; // @SerializedName("_id") // private Long id; // @SerializedName("default") // private Boolean byDefault; // @SerializedName("url_template") // private String urlTemplate; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getAvailability() { // return availability; // } // // public void setAvailability(Integer availability) { // this.availability = availability; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Boolean getByDefault() { // return byDefault; // } // // public void setByDefault(Boolean byDefault) { // this.byDefault = byDefault; // } // // public String getUrlTemplate() { // return urlTemplate; // } // // public void setUrlTemplate(String urlTemplate) { // this.urlTemplate = urlTemplate; // } // } // Path: src/test/java/com/deswaef/twitch/api/ingests/IngestsResourceTest.java import com.deswaef.twitch.api.ingests.domain.Ingest; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat; package com.deswaef.twitch.api.ingests; public class IngestsResourceTest { private IngestsResource ingestsResource; private RestAdapter restAdapter; @Before public void init() { restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.twitch.tv/kraken") .build(); ingestsResource = new IngestsResource().url(restAdapter); } @Test public void ingestsReturnsAllIngests() { assertThat(ingestsResource.ingests()).isNotEmpty(); } @Test public void ingestsHaveValidFields() { ingestsResource .ingests() .stream() .forEach(this::validateIngest); }
private void validateIngest(Ingest ingest) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/configuration/Twitch.java
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // }
import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter;
package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams;
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // } // Path: src/main/java/com/deswaef/twitch/configuration/Twitch.java import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter; package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams;
private ChannelResource channels;
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/configuration/Twitch.java
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // }
import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter;
package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams; private ChannelResource channels;
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // } // Path: src/main/java/com/deswaef/twitch/configuration/Twitch.java import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter; package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams; private ChannelResource channels;
private AccessTokenResource accessTokenResource;
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/configuration/Twitch.java
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // }
import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter;
package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams; private ChannelResource channels; private AccessTokenResource accessTokenResource;
// Path: src/main/java/com/deswaef/twitch/api/channels/ChannelResource.java // public class ChannelResource { // // private ChannelService channelService; // // // public Optional<TwitchChannel> channel(String channelName) { // Assert.notNull(channelName, "please enter a channelname"); // try { // return Optional.ofNullable(channelService.channel(channelName)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public ChannelResource url(RestAdapter url) { // this.channelService = url.create(ChannelService.class); // return this; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/oauth/AccessTokenResource.java // public class AccessTokenResource { // // private AccessTokenService accessTokenService; // // private AccessTokenRequest requestTemplate; // // public AccessTokenResource() { // super(); // requestTemplate = new AccessTokenRequest(); // } // // public AccessTokenResponse requestToken(String accessCode) { // try { // return accessTokenService.requestToken(requestTemplate.copy(accessCode)); // } catch(Exception ex) { // return AccessTokenResponse.unknown_issue(); // } // } // // public AccessTokenResource setClientId(String clientId) { // this.requestTemplate.setClient_id(clientId); // return this; // } // // // public AccessTokenResource setClientSecret(String clientSecret) { // this.requestTemplate.setClient_secret(clientSecret); // return this; // } // // public AccessTokenResource setRedirectUrl(String redirectUrl) { // this.requestTemplate.setRedirect_uri(redirectUrl); // return this; // } // // public AccessTokenResource setBaseUrl(RestAdapter restAdaptor) { // this.accessTokenService = restAdaptor.create(AccessTokenService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java // public class UserResource { // // private UserService userService; // // public Optional<User> user(String user) { // try { // return Optional.ofNullable(userService.user(user)); // } catch (Exception ex) { // return Optional.empty(); // } // } // // public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{ // try { // return Optional.ofNullable(userService.authenticatedUser(accessToken)); // } catch (Exception ex) { // throw new UnAuthorizedException(); // } // } // // // public UserResource url(RestAdapter restAdapter) { // this.userService = restAdapter.create(UserService.class); // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/StreamResource.java // public class StreamResource { // // private StreamService streamService; // // /** // * returns a list of the current top streams // * // * @return List of TwitchStream // */ // public List<TwitchStream> streams() { // try { // return Arrays.asList( // streamService.streams() // .getStreams()); // } catch (Exception ex) { // return new ArrayList<>(); // } // } // // /** // * Returns an Optional of Streamcheck. // * If the stream does not exist, the optional is empty. // * Otherwise, utility methods in the StreamCheck will tell you if the stream is online or not. // * // * @param stream String name of the stream // * @return Optional of StreamCheck // */ // public Optional<StreamCheck> stream(String stream) { // Assert.notNull(stream, "url for stream must not be null"); // try { // return Optional.of(streamService.stream(stream)); // } catch (Exception exception) { // return Optional.empty(); // } // } // // public StreamResource url(RestAdapter restAdapter) { // this.streamService = restAdapter.create(StreamService.class); // return this; // } // // } // Path: src/main/java/com/deswaef/twitch/configuration/Twitch.java import com.deswaef.twitch.api.channels.ChannelResource; import com.deswaef.twitch.api.oauth.AccessTokenResource; import com.deswaef.twitch.api.user.UserResource; import com.deswaef.twitch.api.streams.StreamResource; import retrofit.RestAdapter; package com.deswaef.twitch.configuration; public class Twitch { private StreamResource streams; private ChannelResource channels; private AccessTokenResource accessTokenResource;
private UserResource userResource;
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/user/UserService.java
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // }
import com.deswaef.twitch.api.user.domain.User; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query;
package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 5-7-2015 * Time: 00:44 * * @author Quinten De Swaef */ public interface UserService { @GET("/users/{user}")
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // Path: src/main/java/com/deswaef/twitch/api/user/UserService.java import com.deswaef.twitch.api.user.domain.User; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 5-7-2015 * Time: 00:44 * * @author Quinten De Swaef */ public interface UserService { @GET("/users/{user}")
User user(@Path("user") String user);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/videos/VideoService.java
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // }
import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.http.GET; import retrofit.http.Path; import java.util.List;
package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 5-7-2015 * Time: 00:49 * * @author Quinten De Swaef */ public interface VideoService { @GET("/videos/{id}")
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // } // Path: src/main/java/com/deswaef/twitch/api/videos/VideoService.java import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.http.GET; import retrofit.http.Path; import java.util.List; package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 5-7-2015 * Time: 00:49 * * @author Quinten De Swaef */ public interface VideoService { @GET("/videos/{id}")
Video video(@Path("id")String id);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/videos/VideoService.java
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // }
import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.http.GET; import retrofit.http.Path; import java.util.List;
package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 5-7-2015 * Time: 00:49 * * @author Quinten De Swaef */ public interface VideoService { @GET("/videos/{id}") Video video(@Path("id")String id); @GET("/channels/{channel}/videos")
// Path: src/main/java/com/deswaef/twitch/api/videos/domain/Video.java // public class Video { // private String title; // private String description; // @SerializedName("broadcast_id") // private Long broadcastId; // @SerializedName("_id") // private String id; // private Long length; // private String preview; // private String url; // private Long views; // private String game; // @SerializedName("recorded_at") // private Date recordedAt; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Long getBroadcastId() { // return broadcastId; // } // // public void setBroadcastId(Long broadcastId) { // this.broadcastId = broadcastId; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public Long getLength() { // return length; // } // // public void setLength(Long length) { // this.length = length; // } // // public String getPreview() { // return preview; // } // // public void setPreview(String preview) { // this.preview = preview; // } // // public Long getViews() { // return views; // } // // public void setViews(Long views) { // this.views = views; // } // // public String getGame() { // return game; // } // // public void setGame(String game) { // this.game = game; // } // // public Date getRecordedAt() { // return recordedAt; // } // // public void setRecordedAt(Date recordedAt) { // this.recordedAt = recordedAt; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // } // // Path: src/main/java/com/deswaef/twitch/api/videos/domain/VideosResponse.java // public class VideosResponse { // private List<Video> videos; // // public List<Video> getVideos() { // return videos; // } // // public void setVideos(List<Video> videos) { // this.videos = videos; // } // } // Path: src/main/java/com/deswaef/twitch/api/videos/VideoService.java import com.deswaef.twitch.api.videos.domain.Video; import com.deswaef.twitch.api.videos.domain.VideosResponse; import retrofit.http.GET; import retrofit.http.Path; import java.util.List; package com.deswaef.twitch.api.videos; /** * User: Quinten * Date: 5-7-2015 * Time: 00:49 * * @author Quinten De Swaef */ public interface VideoService { @GET("/videos/{id}") Video video(@Path("id")String id); @GET("/channels/{channel}/videos")
VideosResponse videos(@Path("channel")String channel);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/chat/ChatResource.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); }
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/main/java/com/deswaef/twitch/api/chat/ChatResource.java import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); }
public Optional<ChatLinksInformation> chatUser(String chatUser) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/chat/ChatResource.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); } public Optional<ChatLinksInformation> chatUser(String chatUser) { try { return Optional.ofNullable(chatService.chatUser(chatUser).getChatLinksInformation()); } catch (Exception ex) { return Optional.empty(); } }
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/main/java/com/deswaef/twitch/api/chat/ChatResource.java import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); } public Optional<ChatLinksInformation> chatUser(String chatUser) { try { return Optional.ofNullable(chatService.chatUser(chatUser).getChatLinksInformation()); } catch (Exception ex) { return Optional.empty(); } }
public List<ChatEmoticon> emoticons(String chatUser) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/chat/ChatResource.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional;
package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); } public Optional<ChatLinksInformation> chatUser(String chatUser) { try { return Optional.ofNullable(chatService.chatUser(chatUser).getChatLinksInformation()); } catch (Exception ex) { return Optional.empty(); } } public List<ChatEmoticon> emoticons(String chatUser) { try {
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticon.java // public class ChatEmoticon { // private String regex; // private String url; // private Long height; // private Long width; // @SerializedName("subscriber_only") // private boolean subscriberOnly; // // public String getRegex() { // return regex; // } // // public ChatEmoticon setRegex(String regex) { // this.regex = regex; // return this; // } // // public String getUrl() { // return url; // } // // public ChatEmoticon setUrl(String url) { // this.url = url; // return this; // } // // public Long getHeight() { // return height; // } // // public ChatEmoticon setHeight(Long height) { // this.height = height; // return this; // } // // public Long getWidth() { // return width; // } // // public ChatEmoticon setWidth(Long width) { // this.width = width; // return this; // } // // public boolean isSubscriberOnly() { // return subscriberOnly; // } // // public ChatEmoticon setSubscriberOnly(boolean subscriberOnly) { // this.subscriberOnly = subscriberOnly; // return this; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/main/java/com/deswaef/twitch/api/chat/ChatResource.java import com.deswaef.twitch.api.chat.domain.ChatEmoticon; import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.RestAdapter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 19-9-2014 * Time: 14:44 * * @author Quinten De Swaef */ public class ChatResource { private ChatService chatService; public ChatResource() { super(); } public Optional<ChatLinksInformation> chatUser(String chatUser) { try { return Optional.ofNullable(chatService.chatUser(chatUser).getChatLinksInformation()); } catch (Exception ex) { return Optional.empty(); } } public List<ChatEmoticon> emoticons(String chatUser) { try {
ChatEmoticonsInformation forObject = chatService.emoticons(chatUser);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/streams/StreamService.java
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/Streams.java // public class Streams { // private TwitchStream[] streams; // // public TwitchStream[] getStreams() { // return streams; // } // // public void setStreams(TwitchStream[] streams) { // this.streams = streams; // } // // @Override // public String toString() { // return "Streams{" + // "streams=" + Arrays.toString(streams) + // '}'; // } // }
import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.Streams; import retrofit.http.GET; import retrofit.http.Path;
package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 5-7-2015 * Time: 00:58 * * @author Quinten De Swaef */ public interface StreamService { @GET("/streams")
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/Streams.java // public class Streams { // private TwitchStream[] streams; // // public TwitchStream[] getStreams() { // return streams; // } // // public void setStreams(TwitchStream[] streams) { // this.streams = streams; // } // // @Override // public String toString() { // return "Streams{" + // "streams=" + Arrays.toString(streams) + // '}'; // } // } // Path: src/main/java/com/deswaef/twitch/api/streams/StreamService.java import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.Streams; import retrofit.http.GET; import retrofit.http.Path; package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 5-7-2015 * Time: 00:58 * * @author Quinten De Swaef */ public interface StreamService { @GET("/streams")
Streams streams();
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/streams/StreamService.java
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/Streams.java // public class Streams { // private TwitchStream[] streams; // // public TwitchStream[] getStreams() { // return streams; // } // // public void setStreams(TwitchStream[] streams) { // this.streams = streams; // } // // @Override // public String toString() { // return "Streams{" + // "streams=" + Arrays.toString(streams) + // '}'; // } // }
import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.Streams; import retrofit.http.GET; import retrofit.http.Path;
package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 5-7-2015 * Time: 00:58 * * @author Quinten De Swaef */ public interface StreamService { @GET("/streams") Streams streams(); @GET("/streams/{stream}")
// Path: src/main/java/com/deswaef/twitch/api/streams/domain/StreamCheck.java // public class StreamCheck { // // private TwitchStream stream; // // public boolean isOnline() { // return stream != null; // } // // public TwitchStream getStream() { // return stream; // } // // public void setStream(TwitchStream stream) { // this.stream = stream; // } // } // // Path: src/main/java/com/deswaef/twitch/api/streams/domain/Streams.java // public class Streams { // private TwitchStream[] streams; // // public TwitchStream[] getStreams() { // return streams; // } // // public void setStreams(TwitchStream[] streams) { // this.streams = streams; // } // // @Override // public String toString() { // return "Streams{" + // "streams=" + Arrays.toString(streams) + // '}'; // } // } // Path: src/main/java/com/deswaef/twitch/api/streams/StreamService.java import com.deswaef.twitch.api.streams.domain.StreamCheck; import com.deswaef.twitch.api.streams.domain.Streams; import retrofit.http.GET; import retrofit.http.Path; package com.deswaef.twitch.api.streams; /** * User: Quinten * Date: 5-7-2015 * Time: 00:58 * * @author Quinten De Swaef */ public interface StreamService { @GET("/streams") Streams streams(); @GET("/streams/{stream}")
StreamCheck stream(@Path("stream") String stream);
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/games/GamesResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/games/domain/Game.java // public class Game { // // @SerializedName("_id") // private Long id; // @SerializedName("giantbomb_id") // private Long giantbombId; // @SerializedName("box") // private GameImage box; // @SerializedName("logo") // private GameImage logo; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Long getGiantbombId() { // return giantbombId; // } // // public void setGiantbombId(Long giantbombId) { // this.giantbombId = giantbombId; // } // // public GameImage getBox() { // return box; // } // // public void setBox(GameImage box) { // this.box = box; // } // // public GameImage getLogo() { // return logo; // } // // public void setLogo(GameImage logo) { // this.logo = logo; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameImage.java // public class GameImage { // // private String large; // private String medium; // private String small; // private String template; // // public String getLarge() { // return large; // } // // public void setLarge(String large) { // this.large = large; // } // // public String getMedium() { // return medium; // } // // public void setMedium(String medium) { // this.medium = medium; // } // // public String getSmall() { // return small; // } // // public void setSmall(String small) { // this.small = small; // } // // public String getTemplate() { // return template; // } // // public void setTemplate(String template) { // this.template = template; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResult.java // public class GameTopResult { // // private Game game; // private Long viewers; // private Long channels; // // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // public Long getChannels() { // return channels; // } // // public void setChannels(Long channels) { // this.channels = channels; // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // }
import com.deswaef.twitch.api.games.domain.Game; import com.deswaef.twitch.api.games.domain.GameImage; import com.deswaef.twitch.api.games.domain.GameTopResult; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat;
assertThat(gamesResource.top().get().getTop().size()).isEqualTo(10); } @Test public void topHasValidGames() { gamesResource.top().get().getTop().stream() .map(x -> x.getGame()) .forEach( this::validateGame ); } @Test public void topHasValidGameLogos(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getLogo()) .forEach( this::validateImage ); } @Test public void topHasValidBox(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getBox()) .forEach( this::validateImage ); }
// Path: src/main/java/com/deswaef/twitch/api/games/domain/Game.java // public class Game { // // @SerializedName("_id") // private Long id; // @SerializedName("giantbomb_id") // private Long giantbombId; // @SerializedName("box") // private GameImage box; // @SerializedName("logo") // private GameImage logo; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Long getGiantbombId() { // return giantbombId; // } // // public void setGiantbombId(Long giantbombId) { // this.giantbombId = giantbombId; // } // // public GameImage getBox() { // return box; // } // // public void setBox(GameImage box) { // this.box = box; // } // // public GameImage getLogo() { // return logo; // } // // public void setLogo(GameImage logo) { // this.logo = logo; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameImage.java // public class GameImage { // // private String large; // private String medium; // private String small; // private String template; // // public String getLarge() { // return large; // } // // public void setLarge(String large) { // this.large = large; // } // // public String getMedium() { // return medium; // } // // public void setMedium(String medium) { // this.medium = medium; // } // // public String getSmall() { // return small; // } // // public void setSmall(String small) { // this.small = small; // } // // public String getTemplate() { // return template; // } // // public void setTemplate(String template) { // this.template = template; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResult.java // public class GameTopResult { // // private Game game; // private Long viewers; // private Long channels; // // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // public Long getChannels() { // return channels; // } // // public void setChannels(Long channels) { // this.channels = channels; // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // } // Path: src/test/java/com/deswaef/twitch/api/games/GamesResourceTest.java import com.deswaef.twitch.api.games.domain.Game; import com.deswaef.twitch.api.games.domain.GameImage; import com.deswaef.twitch.api.games.domain.GameTopResult; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat; assertThat(gamesResource.top().get().getTop().size()).isEqualTo(10); } @Test public void topHasValidGames() { gamesResource.top().get().getTop().stream() .map(x -> x.getGame()) .forEach( this::validateGame ); } @Test public void topHasValidGameLogos(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getLogo()) .forEach( this::validateImage ); } @Test public void topHasValidBox(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getBox()) .forEach( this::validateImage ); }
private void validateImage(GameImage gameImage) {
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/games/GamesResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/games/domain/Game.java // public class Game { // // @SerializedName("_id") // private Long id; // @SerializedName("giantbomb_id") // private Long giantbombId; // @SerializedName("box") // private GameImage box; // @SerializedName("logo") // private GameImage logo; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Long getGiantbombId() { // return giantbombId; // } // // public void setGiantbombId(Long giantbombId) { // this.giantbombId = giantbombId; // } // // public GameImage getBox() { // return box; // } // // public void setBox(GameImage box) { // this.box = box; // } // // public GameImage getLogo() { // return logo; // } // // public void setLogo(GameImage logo) { // this.logo = logo; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameImage.java // public class GameImage { // // private String large; // private String medium; // private String small; // private String template; // // public String getLarge() { // return large; // } // // public void setLarge(String large) { // this.large = large; // } // // public String getMedium() { // return medium; // } // // public void setMedium(String medium) { // this.medium = medium; // } // // public String getSmall() { // return small; // } // // public void setSmall(String small) { // this.small = small; // } // // public String getTemplate() { // return template; // } // // public void setTemplate(String template) { // this.template = template; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResult.java // public class GameTopResult { // // private Game game; // private Long viewers; // private Long channels; // // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // public Long getChannels() { // return channels; // } // // public void setChannels(Long channels) { // this.channels = channels; // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // }
import com.deswaef.twitch.api.games.domain.Game; import com.deswaef.twitch.api.games.domain.GameImage; import com.deswaef.twitch.api.games.domain.GameTopResult; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat;
this::validateGame ); } @Test public void topHasValidGameLogos(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getLogo()) .forEach( this::validateImage ); } @Test public void topHasValidBox(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getBox()) .forEach( this::validateImage ); } private void validateImage(GameImage gameImage) { assertThat(gameImage.getLarge()).isNotEmpty(); assertThat(gameImage.getMedium()).isNotEmpty(); assertThat(gameImage.getSmall()).isNotEmpty(); assertThat(gameImage.getTemplate()).isNotEmpty(); }
// Path: src/main/java/com/deswaef/twitch/api/games/domain/Game.java // public class Game { // // @SerializedName("_id") // private Long id; // @SerializedName("giantbomb_id") // private Long giantbombId; // @SerializedName("box") // private GameImage box; // @SerializedName("logo") // private GameImage logo; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Long getGiantbombId() { // return giantbombId; // } // // public void setGiantbombId(Long giantbombId) { // this.giantbombId = giantbombId; // } // // public GameImage getBox() { // return box; // } // // public void setBox(GameImage box) { // this.box = box; // } // // public GameImage getLogo() { // return logo; // } // // public void setLogo(GameImage logo) { // this.logo = logo; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameImage.java // public class GameImage { // // private String large; // private String medium; // private String small; // private String template; // // public String getLarge() { // return large; // } // // public void setLarge(String large) { // this.large = large; // } // // public String getMedium() { // return medium; // } // // public void setMedium(String medium) { // this.medium = medium; // } // // public String getSmall() { // return small; // } // // public void setSmall(String small) { // this.small = small; // } // // public String getTemplate() { // return template; // } // // public void setTemplate(String template) { // this.template = template; // } // } // // Path: src/main/java/com/deswaef/twitch/api/games/domain/GameTopResult.java // public class GameTopResult { // // private Game game; // private Long viewers; // private Long channels; // // // public Long getViewers() { // return viewers; // } // // public void setViewers(Long viewers) { // this.viewers = viewers; // } // // public Long getChannels() { // return channels; // } // // public void setChannels(Long channels) { // this.channels = channels; // } // // public Game getGame() { // return game; // } // // public void setGame(Game game) { // this.game = game; // } // } // Path: src/test/java/com/deswaef/twitch/api/games/GamesResourceTest.java import com.deswaef.twitch.api.games.domain.Game; import com.deswaef.twitch.api.games.domain.GameImage; import com.deswaef.twitch.api.games.domain.GameTopResult; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import retrofit.RestAdapter; import static org.fest.assertions.Assertions.assertThat; this::validateGame ); } @Test public void topHasValidGameLogos(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getLogo()) .forEach( this::validateImage ); } @Test public void topHasValidBox(){ gamesResource.top().get().getTop().stream() .map(x -> x.getGame().getBox()) .forEach( this::validateImage ); } private void validateImage(GameImage gameImage) { assertThat(gameImage.getLarge()).isNotEmpty(); assertThat(gameImage.getMedium()).isNotEmpty(); assertThat(gameImage.getSmall()).isNotEmpty(); assertThat(gameImage.getTemplate()).isNotEmpty(); }
private void validateGame(Game game) {
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/api/user/UserResourceTest.java
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // }
import com.deswaef.twitch.api.user.domain.User; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package com.deswaef.twitch.api.user; @RunWith(MockitoJUnitRunner.class) public class UserResourceTest { public static final String TOKEN = "this_is_token"; public static final String BASE_URL = "https://api.twitch.tv/kraken"; public RestAdapter restAdapter; private UserResource userResource; @Before public void init() { restAdapter = new RestAdapter.Builder().setEndpoint(BASE_URL).build(); userResource = new UserResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { userResource = new UserResource().url(restAdapter); assertThat(new Mirror().on(userResource).get().field("userService")).isNotNull(); } @Test public void getPublicUser() {
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // Path: src/test/java/com/deswaef/twitch/api/user/UserResourceTest.java import com.deswaef.twitch.api.user.domain.User; import net.vidageek.mirror.dsl.Mirror; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import retrofit.RestAdapter; import java.util.Optional; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package com.deswaef.twitch.api.user; @RunWith(MockitoJUnitRunner.class) public class UserResourceTest { public static final String TOKEN = "this_is_token"; public static final String BASE_URL = "https://api.twitch.tv/kraken"; public RestAdapter restAdapter; private UserResource userResource; @Before public void init() { restAdapter = new RestAdapter.Builder().setEndpoint(BASE_URL).build(); userResource = new UserResource().url(restAdapter); } @Test public void initializedAndUrlIsSet() { userResource = new UserResource().url(restAdapter); assertThat(new Mirror().on(userResource).get().field("userService")).isNotNull(); } @Test public void getPublicUser() {
Optional<User> streamingforanimals = userResource.user("streamingforanimals");
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/user/UserResource.java
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // }
import com.deswaef.twitch.api.user.domain.User; import com.deswaef.twitch.exception.UnAuthorizedException; import retrofit.RestAdapter; import java.util.Optional;
package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 16-9-2014 * Time: 22:19 * * @author Quinten De Swaef */ public class UserResource { private UserService userService;
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java import com.deswaef.twitch.api.user.domain.User; import com.deswaef.twitch.exception.UnAuthorizedException; import retrofit.RestAdapter; import java.util.Optional; package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 16-9-2014 * Time: 22:19 * * @author Quinten De Swaef */ public class UserResource { private UserService userService;
public Optional<User> user(String user) {
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/user/UserResource.java
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // }
import com.deswaef.twitch.api.user.domain.User; import com.deswaef.twitch.exception.UnAuthorizedException; import retrofit.RestAdapter; import java.util.Optional;
package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 16-9-2014 * Time: 22:19 * * @author Quinten De Swaef */ public class UserResource { private UserService userService; public Optional<User> user(String user) { try { return Optional.ofNullable(userService.user(user)); } catch (Exception ex) { return Optional.empty(); } }
// Path: src/main/java/com/deswaef/twitch/api/user/domain/User.java // public class User { // // private String name; // @SerializedName(value = "created_at") // private Date createdAt; // @SerializedName(value = "updated_at") // private Date updatedAt; // private String logo; // @SerializedName(value = "_id") // private Long id; // private String email; // @SerializedName("display_name") // private String displayName; // private boolean partnered; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Date getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(Date createdAt) { // this.createdAt = createdAt; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(Date updatedAt) { // this.updatedAt = updatedAt; // } // // public String getLogo() { // return logo; // } // // public void setLogo(String logo) { // this.logo = logo; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public boolean isPartnered() { // return partnered; // } // // public void setPartnered(boolean partnered) { // this.partnered = partnered; // } // } // // Path: src/main/java/com/deswaef/twitch/exception/UnAuthorizedException.java // public class UnAuthorizedException extends TwitchException { // } // Path: src/main/java/com/deswaef/twitch/api/user/UserResource.java import com.deswaef.twitch.api.user.domain.User; import com.deswaef.twitch.exception.UnAuthorizedException; import retrofit.RestAdapter; import java.util.Optional; package com.deswaef.twitch.api.user; /** * User: Quinten * Date: 16-9-2014 * Time: 22:19 * * @author Quinten De Swaef */ public class UserResource { private UserService userService; public Optional<User> user(String user) { try { return Optional.ofNullable(userService.user(user)); } catch (Exception ex) { return Optional.empty(); } }
public Optional<User> getAuthenticatedUser(String accessToken) throws UnAuthorizedException{
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/chat/ChatService.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.http.GET; import retrofit.http.Path;
package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 5-7-2015 * Time: 01:11 * * @author Quinten De Swaef */ public interface ChatService { @GET("/chat/{chatUser}")
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/main/java/com/deswaef/twitch/api/chat/ChatService.java import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.http.GET; import retrofit.http.Path; package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 5-7-2015 * Time: 01:11 * * @author Quinten De Swaef */ public interface ChatService { @GET("/chat/{chatUser}")
ChatInformation chatUser(@Path("chatUser")String chatUser);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/chat/ChatService.java
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // }
import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.http.GET; import retrofit.http.Path;
package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 5-7-2015 * Time: 01:11 * * @author Quinten De Swaef */ public interface ChatService { @GET("/chat/{chatUser}") ChatInformation chatUser(@Path("chatUser")String chatUser); @GET("/chat/{chatUser}/emoticons")
// Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatEmoticonsInformation.java // public class ChatEmoticonsInformation { // // private List<ChatEmoticon> emoticons; // // public List<ChatEmoticon> getEmoticons() { // return emoticons; // } // // public void setEmoticons(List<ChatEmoticon> emoticons) { // this.emoticons = emoticons; // } // // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatInformation.java // public class ChatInformation { // // @SerializedName("_links") // private ChatLinksInformation chatLinksInformation; // // public ChatLinksInformation getChatLinksInformation() { // return chatLinksInformation; // } // // public void setChatLinksInformation(ChatLinksInformation chatLinksInformation) { // this.chatLinksInformation = chatLinksInformation; // } // } // // Path: src/main/java/com/deswaef/twitch/api/chat/domain/ChatLinksInformation.java // public class ChatLinksInformation { // // @SerializedName("emoticons") // private String emoticonsUrl; // @SerializedName("badges") // private String badgesUrl; // // public String getEmoticonsUrl() { // return emoticonsUrl; // } // // public void setEmoticonsUrl(String emoticonsUrl) { // this.emoticonsUrl = emoticonsUrl; // } // // public String getBadgesUrl() { // return badgesUrl; // } // // public void setBadgesUrl(String badgesUrl) { // this.badgesUrl = badgesUrl; // } // } // Path: src/main/java/com/deswaef/twitch/api/chat/ChatService.java import com.deswaef.twitch.api.chat.domain.ChatEmoticonsInformation; import com.deswaef.twitch.api.chat.domain.ChatInformation; import com.deswaef.twitch.api.chat.domain.ChatLinksInformation; import retrofit.http.GET; import retrofit.http.Path; package com.deswaef.twitch.api.chat; /** * User: Quinten * Date: 5-7-2015 * Time: 01:11 * * @author Quinten De Swaef */ public interface ChatService { @GET("/chat/{chatUser}") ChatInformation chatUser(@Path("chatUser")String chatUser); @GET("/chat/{chatUser}/emoticons")
ChatEmoticonsInformation emoticons(@Path("chatUser") String chatUser);
Qkyrie/Twitch
src/main/java/com/deswaef/twitch/api/ingests/IngestsService.java
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // }
import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.http.GET;
package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 5-7-2015 * Time: 00:37 * * @author Quinten De Swaef */ public interface IngestsService { @GET("/ingests")
// Path: src/main/java/com/deswaef/twitch/api/ingests/domain/IngestResult.java // public class IngestResult { // private List<Ingest> ingests; // // public List<Ingest> getIngests() { // return ingests; // } // // public void setIngests(List<Ingest> ingests) { // this.ingests = ingests; // } // } // Path: src/main/java/com/deswaef/twitch/api/ingests/IngestsService.java import com.deswaef.twitch.api.ingests.domain.IngestResult; import retrofit.http.GET; package com.deswaef.twitch.api.ingests; /** * User: Quinten * Date: 5-7-2015 * Time: 00:37 * * @author Quinten De Swaef */ public interface IngestsService { @GET("/ingests")
IngestResult ingests();
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/util/AuthorizationURLBuilderTest.java
// Path: src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java // public static AuthorizationURLBuilder buildAuthorizationUrl() { // return new AuthorizationURLBuilder(); // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // }
import org.junit.Test; import static com.deswaef.twitch.util.AuthorizationURLBuilder.buildAuthorizationUrl; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat;
package com.deswaef.twitch.util; public class AuthorizationURLBuilderTest { public static final String SCOPE_1 = "scope1"; public static final String SCOPE_2 = "scope2"; public static final String REDIRECT_URI = "redirectURI"; public static final String CLIENT_ID = "clientId"; public static final String BASE_URL = "baseUrl"; @Test public void baseUrlShouldBeSet() {
// Path: src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java // public static AuthorizationURLBuilder buildAuthorizationUrl() { // return new AuthorizationURLBuilder(); // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // } // Path: src/test/java/com/deswaef/twitch/util/AuthorizationURLBuilderTest.java import org.junit.Test; import static com.deswaef.twitch.util.AuthorizationURLBuilder.buildAuthorizationUrl; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat; package com.deswaef.twitch.util; public class AuthorizationURLBuilderTest { public static final String SCOPE_1 = "scope1"; public static final String SCOPE_2 = "scope2"; public static final String REDIRECT_URI = "redirectURI"; public static final String CLIENT_ID = "clientId"; public static final String BASE_URL = "baseUrl"; @Test public void baseUrlShouldBeSet() {
assertThrown(
Qkyrie/Twitch
src/test/java/com/deswaef/twitch/util/AuthorizationURLBuilderTest.java
// Path: src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java // public static AuthorizationURLBuilder buildAuthorizationUrl() { // return new AuthorizationURLBuilder(); // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // }
import org.junit.Test; import static com.deswaef.twitch.util.AuthorizationURLBuilder.buildAuthorizationUrl; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat;
package com.deswaef.twitch.util; public class AuthorizationURLBuilderTest { public static final String SCOPE_1 = "scope1"; public static final String SCOPE_2 = "scope2"; public static final String REDIRECT_URI = "redirectURI"; public static final String CLIENT_ID = "clientId"; public static final String BASE_URL = "baseUrl"; @Test public void baseUrlShouldBeSet() { assertThrown(
// Path: src/main/java/com/deswaef/twitch/util/AuthorizationURLBuilder.java // public static AuthorizationURLBuilder buildAuthorizationUrl() { // return new AuthorizationURLBuilder(); // } // // Path: src/test/java/com/deswaef/twitch/util/ThrowableAssertion.java // public static ThrowableAssertion assertThrown(ExceptionThrower exceptionThrower) { // try { // exceptionThrower.throwException(); // } catch (Throwable caught) { // return new ThrowableAssertion(caught); // } // throw new ExceptionNotThrownAssertionError(); // } // Path: src/test/java/com/deswaef/twitch/util/AuthorizationURLBuilderTest.java import org.junit.Test; import static com.deswaef.twitch.util.AuthorizationURLBuilder.buildAuthorizationUrl; import static com.deswaef.twitch.util.ThrowableAssertion.assertThrown; import static org.fest.assertions.Assertions.assertThat; package com.deswaef.twitch.util; public class AuthorizationURLBuilderTest { public static final String SCOPE_1 = "scope1"; public static final String SCOPE_2 = "scope2"; public static final String REDIRECT_URI = "redirectURI"; public static final String CLIENT_ID = "clientId"; public static final String BASE_URL = "baseUrl"; @Test public void baseUrlShouldBeSet() { assertThrown(
() -> buildAuthorizationUrl()
situx/SemanticDictionary
src/main/java/com/github/situx/cunei/dict/utils/POSTag.java
// Path: src/main/java/com/github/situx/cunei/util/enums/pos/POSTags.java // public enum POSTags { // // // AGENT("AGENT","http://purl.org/olia/olia.owl#Agent"), // ADJECTIVE("ADJ","http://purl.org/olia/olia.owl#Adjective"), // ADVERB("ADV","http://purl.org/olia/olia.owl#Adverb"), // DETERMINATIVE("DET","http://purl.org/olia/olia.owl#Determiner"), // CONJUNCTION("CONJ","http://purl.org/olia/olia.owl#Conjunction"), // INDEFINITEPRONOUN("INDPRO","http://purl.org/olia/olia.owl#IndefinitePronoun"), // DEMONSTRATIVEPRONOUN("DEMPRO","http://purl.org/olia/olia.owl#DemonstrativePronoun"), // MODALPREFIX("MOD","http://purl.org/olia/olia.owl#Modal"), // NOUN("NN","http://purl.org/olia/olia.owl#Noun"), // NOUNORADJ("NA","http://purl.org/olia/olia.owl#NounOrAdjective"), // NAMEDENTITY("NE","http://purl.org/olia/olia.owl#NamedEntity"), // NUMBER("CARD","http://purl.org/olia/olia.owl#Cardinal"), // PARTICLE("PART","http://purl.org/olia/olia.owl#Particle"), // RELATIVEPRONOUN("RELPRO","http://purl.org/olia/olia.owl#RelativePronoun"), // POSSESSIVE("POSS","http://purl.org/olia/olia.owl#Possessive"), // PRECATIVE("PRE","http://purl.org/olia/olia.owl#Precative"), // POSTPOSITION("POSTPOS","http://purl.org/olia/olia.owl#Postposition"), // PRONOUN("PRO","http://purl.org/olia/olia.owl#Pronoun"), // UNKNOWN("UNKNOWN","http://purl.org/olia/olia.owl#Unknown"), // VERB("VV","http://purl.org/olia/olia.owl#Verb"), // SUBJECT("SUBJECT","http://purl.org/olia/olia.owl#Subject"), // OBJECT("OBJ","http://purl.org/olia/olia.owl#Object"), // PREPOSITION("PREP","http://purl.org/olia/olia.owl#Preposition"); // // private String tagdesc; // // private String uri; // // public String getUri() { // return uri; // } // // private POSTags(String tagdesc, String uri){ // this.tagdesc=tagdesc; // this.uri=uri; // // } // // @Override // public String toString() { // return this.tagdesc; // } // }
import com.github.situx.cunei.akkad.util.enums.pos.POSTags;
package com.github.situx.cunei.akkad.dict.utils; /** * Created by timo on 03.07.14. */ public class POSTag implements Comparable<POSTag>{ public String getConceptURI() { return conceptURI; } public void setConceptURI(String conceptURI) { this.conceptURI = conceptURI; }
// Path: src/main/java/com/github/situx/cunei/util/enums/pos/POSTags.java // public enum POSTags { // // // AGENT("AGENT","http://purl.org/olia/olia.owl#Agent"), // ADJECTIVE("ADJ","http://purl.org/olia/olia.owl#Adjective"), // ADVERB("ADV","http://purl.org/olia/olia.owl#Adverb"), // DETERMINATIVE("DET","http://purl.org/olia/olia.owl#Determiner"), // CONJUNCTION("CONJ","http://purl.org/olia/olia.owl#Conjunction"), // INDEFINITEPRONOUN("INDPRO","http://purl.org/olia/olia.owl#IndefinitePronoun"), // DEMONSTRATIVEPRONOUN("DEMPRO","http://purl.org/olia/olia.owl#DemonstrativePronoun"), // MODALPREFIX("MOD","http://purl.org/olia/olia.owl#Modal"), // NOUN("NN","http://purl.org/olia/olia.owl#Noun"), // NOUNORADJ("NA","http://purl.org/olia/olia.owl#NounOrAdjective"), // NAMEDENTITY("NE","http://purl.org/olia/olia.owl#NamedEntity"), // NUMBER("CARD","http://purl.org/olia/olia.owl#Cardinal"), // PARTICLE("PART","http://purl.org/olia/olia.owl#Particle"), // RELATIVEPRONOUN("RELPRO","http://purl.org/olia/olia.owl#RelativePronoun"), // POSSESSIVE("POSS","http://purl.org/olia/olia.owl#Possessive"), // PRECATIVE("PRE","http://purl.org/olia/olia.owl#Precative"), // POSTPOSITION("POSTPOS","http://purl.org/olia/olia.owl#Postposition"), // PRONOUN("PRO","http://purl.org/olia/olia.owl#Pronoun"), // UNKNOWN("UNKNOWN","http://purl.org/olia/olia.owl#Unknown"), // VERB("VV","http://purl.org/olia/olia.owl#Verb"), // SUBJECT("SUBJECT","http://purl.org/olia/olia.owl#Subject"), // OBJECT("OBJ","http://purl.org/olia/olia.owl#Object"), // PREPOSITION("PREP","http://purl.org/olia/olia.owl#Preposition"); // // private String tagdesc; // // private String uri; // // public String getUri() { // return uri; // } // // private POSTags(String tagdesc, String uri){ // this.tagdesc=tagdesc; // this.uri=uri; // // } // // @Override // public String toString() { // return this.tagdesc; // } // } // Path: src/main/java/com/github/situx/cunei/dict/utils/POSTag.java import com.github.situx.cunei.akkad.util.enums.pos.POSTags; package com.github.situx.cunei.akkad.dict.utils; /** * Created by timo on 03.07.14. */ public class POSTag implements Comparable<POSTag>{ public String getConceptURI() { return conceptURI; } public void setConceptURI(String conceptURI) { this.conceptURI = conceptURI; }
private POSTags postag=POSTags.NOUN;
situx/SemanticDictionary
src/main/java/com/github/situx/cunei/dict/chars/cuneiform/AkkadChar.java
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // }
import com.github.situx.cunei.akkad.util.enums.methods.CharTypes;
package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Represents an akkadian character/word. */ public class AkkadChar extends CuneiChar { /** * Constructor for this class. * @param character the character to use */ public AkkadChar(final String character){ super(character);
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // } // Path: src/main/java/com/github/situx/cunei/dict/chars/cuneiform/AkkadChar.java import com.github.situx.cunei.akkad.util.enums.methods.CharTypes; package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Represents an akkadian character/word. */ public class AkkadChar extends CuneiChar { /** * Constructor for this class. * @param character the character to use */ public AkkadChar(final String character){ super(character);
this.charlength= CharTypes.AKKADIAN.getChar_length();
situx/SemanticDictionary
src/main/java/com/github/situx/cunei/dict/chars/cuneiform/HittiteChar.java
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // }
import com.github.situx.cunei.akkad.util.enums.methods.CharTypes;
package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Created with IntelliJ IDEA. * User: timo * Date: 25.10.13 * Time: 12:00 * Class for modelling a hittitian cuneiform character. */ public class HittiteChar extends CuneiChar { public String getHethZLNumber() { return hethZLNumber; } public void setHethZLNumber(final String hethZLNumber) { this.hethZLNumber = hethZLNumber; } private String hethZLNumber; /** * Constructor for this class * @param character the cuneiform character modelled by this class. */ public HittiteChar(final String character){ super(character); this.hethZLNumber="";
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // } // Path: src/main/java/com/github/situx/cunei/dict/chars/cuneiform/HittiteChar.java import com.github.situx.cunei.akkad.util.enums.methods.CharTypes; package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Created with IntelliJ IDEA. * User: timo * Date: 25.10.13 * Time: 12:00 * Class for modelling a hittitian cuneiform character. */ public class HittiteChar extends CuneiChar { public String getHethZLNumber() { return hethZLNumber; } public void setHethZLNumber(final String hethZLNumber) { this.hethZLNumber = hethZLNumber; } private String hethZLNumber; /** * Constructor for this class * @param character the cuneiform character modelled by this class. */ public HittiteChar(final String character){ super(character); this.hethZLNumber="";
this.charlength= CharTypes.HITTITE.getChar_length();
situx/SemanticDictionary
src/main/java/com/github/situx/cunei/dict/chars/cuneiform/SumerianChar.java
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // }
import com.github.situx.cunei.akkad.util.enums.methods.CharTypes;
package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Created with IntelliJ IDEA. * User: timo * Date: 25.10.13 * Time: 12:00 * Class for modelling a sumerian cuneiform character. */ public class SumerianChar extends CuneiChar { private String SHAnumber; /** * Constructor for this class * @param character the cuneiform character modelled by this class. */ public SumerianChar(final String character){ super(character); this.character=character;
// Path: src/main/java/com/github/situx/cunei/util/enums/methods/CharTypes.java // public enum CharTypes implements MethodEnum { // /**Akkadian Char.*/ // AKKADIAN("Akkadian Char","akk",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0X12000,0X12399},"[A-z0-9, -]+","\uD808\uDC2D","akkadian"), // /**Cuneiform Char.*/ // CUNEICHAR("Cuneiform Char",Locale.ENGLISH.toString(),2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[0],".*","","cuneiform"), // /**Hittite Char.*/ // HITTITE("Hittite Char","hit",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","hittite"), // /**Language Char.*/ // LANGCHAR("Language Char",Locale.ENGLISH.toString(),1,".", Arrays.asList(new String[0]),new Integer[0],".*","","lang"), // /**Sumerian Char.*/ // SUMERIAN("Sumerian Char","sux",2,"-", Arrays.asList(new String[]{System.lineSeparator()}),new Integer[]{0x12000,0x12399},"[A-z0-9, -]+","\uD808\uDC2D","sumerian"), // EGYPTIANCHAR("Egyptian Char","egy",1,"(?<=\\p{Nd})", Arrays.asList(new String[]{"。",",","?","!"}),new Integer[0],".*","","egyptian"); // // public String getPreviewString() { // return previewString; // } // // // private final String previewString; // // private final List<String> stopchars; // // private Boolean initialized=false; // private Integer char_length; // private Integer[] unicode_ranges; // private String legalTranslitCharsRegex; // /**String value (name of the method).*/ // private String locale,splitcriterion,smallstr; // /**String value (name of the method).*/ // private String value; // // public String getLegalTranslitCharsRegex() { // return legalTranslitCharsRegex; // } // // public void setLegalTranslitCharsRegex(final String legalTranslitCharsRegex) { // this.legalTranslitCharsRegex = legalTranslitCharsRegex; // } // // // // public String getSmallstr() { // return smallstr; // } // // /**Constructor using a description parameter.*/ // private CharTypes(String value,String locale,Integer char_length,String splitcriterion,final List<String> stopchars,final Integer[] unicode_ranges,final String legalTranslitChars,final String previewString,String smallstr){ // this.value=value; // this.locale=locale; // this.unicode_ranges=unicode_ranges; // this.char_length=char_length; // this.splitcriterion=splitcriterion; // this.stopchars=stopchars; // this.previewString=previewString; // this.legalTranslitCharsRegex =legalTranslitChars; // this.smallstr=smallstr; // // } // // public Integer getChar_length() { // return char_length; // } // // // public String getLocale() { // return locale; // } // // @Override // public String getShortname() { // return null; // } // // public String getSplitcriterion() { // return splitcriterion; // } // // public List<String> getStopchars() { // return stopchars; // } // // @Override // public String toString() { // return this.value; // } // } // Path: src/main/java/com/github/situx/cunei/dict/chars/cuneiform/SumerianChar.java import com.github.situx.cunei.akkad.util.enums.methods.CharTypes; package com.github.situx.cunei.akkad.dict.chars.cuneiform; /** * Created with IntelliJ IDEA. * User: timo * Date: 25.10.13 * Time: 12:00 * Class for modelling a sumerian cuneiform character. */ public class SumerianChar extends CuneiChar { private String SHAnumber; /** * Constructor for this class * @param character the cuneiform character modelled by this class. */ public SumerianChar(final String character){ super(character); this.character=character;
this.charlength= CharTypes.SUMERIAN.getChar_length();
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // }
import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors;
package com.yammer.breakerbox.service.store; /** * TenacityPropertyKeysStore is a component used to track known keys for presentation in the Breakerbox * configuration front-end. Adding keys to any externally hosted data structures happens outside the * context of this class. */ public class TenacityPropertyKeysStore { private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder .newBuilder() .expireAfterWrite(1, TimeUnit.MINUTES) .build();
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; package com.yammer.breakerbox.service.store; /** * TenacityPropertyKeysStore is a component used to track known keys for presentation in the Breakerbox * configuration front-end. Adding keys to any externally hosted data structures happens outside the * context of this class. */ public class TenacityPropertyKeysStore { private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder .newBuilder() .expireAfterWrite(1, TimeUnit.MINUTES) .build();
private final TenacityPoller.Factory tenacityPollerFactory;
yammer/breakerbox
breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import java.util.Objects;
package com.yammer.breakerbox.store.model; public class ServiceModel { private final ServiceId serviceId;
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import java.util.Objects; package com.yammer.breakerbox.store.model; public class ServiceModel { private final ServiceId serviceId;
private final DependencyId dependencyId;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors;
package com.yammer.breakerbox.turbine; /** * Created by supreeth.vp on 23/05/17. */ public class MarathonInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); private final ObjectMapper mapper;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; package com.yammer.breakerbox.turbine; /** * Created by supreeth.vp on 23/05/17. */ public class MarathonInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); private final ObjectMapper mapper;
private MarathonClient marathonClient;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors;
package com.yammer.breakerbox.turbine; /** * Created by supreeth.vp on 23/05/17. */ public class MarathonInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); private final ObjectMapper mapper; private MarathonClient marathonClient;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; package com.yammer.breakerbox.turbine; /** * Created by supreeth.vp on 23/05/17. */ public class MarathonInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); private final ObjectMapper mapper; private MarathonClient marathonClient;
private final List<MarathonClientConfiguration> marathonClientConfigurations;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors;
private void constructMarathonClientConfigurationBuilderMap() { marathonClientConfigurationBuilderMap = new HashMap<>(); marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { marathonClient = new MarathonClient(marathonClientConfiguration); Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); }); } @Override public Collection<Instance> getInstanceList() throws Exception { List<Instance> instances = new ArrayList<>(); marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { Response response = null; try { response = entry.getValue().get(); if (response.getStatus() == HttpStatus.SC_OK) { instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); } } finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) {
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; private void constructMarathonClientConfigurationBuilderMap() { marathonClientConfigurationBuilderMap = new HashMap<>(); marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { marathonClient = new MarathonClient(marathonClientConfiguration); Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); }); } @Override public Collection<Instance> getInstanceList() throws Exception { List<Instance> instances = new ArrayList<>(); marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { Response response = null; try { response = entry.getValue().get(); if (response.getStatus() == HttpStatus.SC_OK) { instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); } } finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) {
MarathonClientResponse marathonClientResponse = null;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors;
} @Override public Collection<Instance> getInstanceList() throws Exception { List<Instance> instances = new ArrayList<>(); marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { Response response = null; try { response = entry.getValue().get(); if (response.getStatus() == HttpStatus.SC_OK) { instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); } } finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { MarathonClientResponse marathonClientResponse = null; try { marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); } catch (IOException e) { LOGGER.error("io exception",e); } if (marathonClientResponse != null && marathonClientResponse.getApp() != null) {
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; } @Override public Collection<Instance> getInstanceList() throws Exception { List<Instance> instances = new ArrayList<>(); marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { Response response = null; try { response = entry.getValue().get(); if (response.getStatus() == HttpStatus.SC_OK) { instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); } } finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { MarathonClientResponse marathonClientResponse = null; try { marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); } catch (IOException e) { LOGGER.error("io exception",e); } if (marathonClientResponse != null && marathonClientResponse.getApp() != null) {
List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings();
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors;
} finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { MarathonClientResponse marathonClientResponse = null; try { marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); } catch (IOException e) { LOGGER.error("io exception",e); } if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); int portIndex = -1; for (int i = 0; i < portMappingList.size(); i++) { if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { portIndex = i; break; } } if (portIndex < 0) { LOGGER.error("marathon app port non present in port mapping"); return Collections.emptyList(); }
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/MarathonClientResponse.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class MarathonClientResponse { // // private App app; // // // public App getApp() { // return app; // } // // public void setApp(App app) { // this.app = app; // } // // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/PortMapping.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class PortMapping { // // private Integer containerPort; // private Integer servicePort; // // public Integer getContainerPort() { // return containerPort; // } // // public void setContainerPort(Integer containerPort) { // this.containerPort = containerPort; // } // // public Integer getServicePort() { // return servicePort; // } // // public void setServicePort(Integer servicePort) { // this.servicePort = servicePort; // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/model/marathon/Task.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class Task { // private String host; // private List<Integer> ports = null; // private String state; // // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public List<Integer> getPorts() { // return ports; // } // // public void setPorts(List<Integer> ports) { // this.ports = ports; // } // // public String getState() { // return state; // } // // public void setState(String state) { // this.state = state; // } // // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.model.marathon.MarathonClientResponse; import com.yammer.breakerbox.turbine.model.marathon.PortMapping; import com.yammer.breakerbox.turbine.model.marathon.Task; import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; } finally { if (response != null) { response.close(); } } }); return instances; } public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { MarathonClientResponse marathonClientResponse = null; try { marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); } catch (IOException e) { LOGGER.error("io exception",e); } if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); int portIndex = -1; for (int i = 0; i < portMappingList.size(); i++) { if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { portIndex = i; break; } } if (portIndex < 0) { LOGGER.error("marathon app port non present in port mapping"); return Collections.emptyList(); }
List<Task> tasks = marathonClientResponse.getApp().getTasks();
yammer/breakerbox
breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import org.joda.time.DateTime; import java.util.Objects;
package com.yammer.breakerbox.store.model; public class DependencyModel { private final DependencyId dependencyId; private final DateTime dateTime; private final TenacityConfiguration tenacityConfiguration; private final String user;
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import org.joda.time.DateTime; import java.util.Objects; package com.yammer.breakerbox.store.model; public class DependencyModel { private final DependencyId dependencyId; private final DateTime dateTime; private final TenacityConfiguration tenacityConfiguration; private final String user;
private final ServiceId serviceId;
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/TurbineTenacityClient.java // public interface TurbineTenacityClient { // Optional<Collection<String>> getTenacityPropertyKeys(Instance instance); // // Optional<TenacityConfiguration> getTenacityConfiguration(Instance instance, TenacityPropertyKey key); // // Optional<Collection<CircuitBreaker>> getCircuitBreakers(Instance instance); // // Optional<CircuitBreaker> getCircuitBreaker(Instance instance, TenacityPropertyKey key); // // Optional<CircuitBreaker> modifyCircuitBreaker(Instance instance, // TenacityPropertyKey key, // CircuitBreaker.State state); // // static URI toUri(Instance instance) { // final String rawHostname = instance.getHostname().trim(); // if (rawHostname.startsWith("http")) { // return URI.create(rawHostname); // } else { // return URI.create("http://" + rawHostname); // } // } // }
import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.client.TurbineTenacityClient; import com.yammer.tenacity.core.TenacityCommand; import java.util.Collection; import java.util.Optional;
package com.yammer.breakerbox.service.tenacity; public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { public static class Factory {
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/TurbineTenacityClient.java // public interface TurbineTenacityClient { // Optional<Collection<String>> getTenacityPropertyKeys(Instance instance); // // Optional<TenacityConfiguration> getTenacityConfiguration(Instance instance, TenacityPropertyKey key); // // Optional<Collection<CircuitBreaker>> getCircuitBreakers(Instance instance); // // Optional<CircuitBreaker> getCircuitBreaker(Instance instance, TenacityPropertyKey key); // // Optional<CircuitBreaker> modifyCircuitBreaker(Instance instance, // TenacityPropertyKey key, // CircuitBreaker.State state); // // static URI toUri(Instance instance) { // final String rawHostname = instance.getHostname().trim(); // if (rawHostname.startsWith("http")) { // return URI.create(rawHostname); // } else { // return URI.create("http://" + rawHostname); // } // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.client.TurbineTenacityClient; import com.yammer.tenacity.core.TenacityCommand; import java.util.Collection; import java.util.Optional; package com.yammer.breakerbox.service.tenacity; public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { public static class Factory {
private final TurbineTenacityClient tenacityClient;
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/ServiceEntity.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.yammer.breakerbox.azure.model; /** * Bean to represent the Service table. * Partitioned by service, each service contains a list of service dependency keys. * As of 5-SEP-2013, these dependency keys are updated by the continuous polling of services' * Tenacity endpoint for DependencyKeys. See TenacityClient for more. */ public class ServiceEntity extends TableType implements TableKey { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class);
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/ServiceEntity.java import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package com.yammer.breakerbox.azure.model; /** * Bean to represent the Service table. * Partitioned by service, each service contains a list of service dependency keys. * As of 5-SEP-2013, these dependency keys are updated by the continuous polling of services' * Tenacity endpoint for DependencyKeys. See TenacityClient for more. */ public class ServiceEntity extends TableType implements TableKey { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class);
private ServiceEntity(ServiceId serviceId,
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/ServiceEntity.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.yammer.breakerbox.azure.model; /** * Bean to represent the Service table. * Partitioned by service, each service contains a list of service dependency keys. * As of 5-SEP-2013, these dependency keys are updated by the continuous polling of services' * Tenacity endpoint for DependencyKeys. See TenacityClient for more. */ public class ServiceEntity extends TableType implements TableKey { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private ServiceEntity(ServiceId serviceId,
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/ServiceEntity.java import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package com.yammer.breakerbox.azure.model; /** * Bean to represent the Service table. * Partitioned by service, each service contains a list of service dependency keys. * As of 5-SEP-2013, these dependency keys are updated by the continuous polling of services' * Tenacity endpoint for DependencyKeys. See TenacityClient for more. */ public class ServiceEntity extends TableType implements TableKey { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private ServiceEntity(ServiceId serviceId,
DependencyId dependencyId) {
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/ScheduledTenacityPoller.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // }
import com.yammer.breakerbox.service.core.Instances; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.yammer.breakerbox.service.store; public class ScheduledTenacityPoller implements Runnable { private final TenacityPropertyKeysStore tenacityPropertyKeysStore; private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTenacityPoller.class); public ScheduledTenacityPoller(TenacityPropertyKeysStore tenacityPropertyKeysStore) { this.tenacityPropertyKeysStore = tenacityPropertyKeysStore; } @Override public void run() { try {
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/ScheduledTenacityPoller.java import com.yammer.breakerbox.service.core.Instances; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package com.yammer.breakerbox.service.store; public class ScheduledTenacityPoller implements Runnable { private final TenacityPropertyKeysStore tenacityPropertyKeysStore; private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTenacityPoller.class); public ScheduledTenacityPoller(TenacityPropertyKeysStore tenacityPropertyKeysStore) { this.tenacityPropertyKeysStore = tenacityPropertyKeysStore; } @Override public void run() { try {
Instances.instances().forEach(tenacityPropertyKeysStore::getTenacityPropertyKeys);
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/config/BreakerboxServiceConfiguration.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/AzureTableConfiguration.java // public class AzureTableConfiguration { // // @NotNull @Valid // private final StorageCredentialsAccountAndKey storageCredentialsAccountAndKey; // @NotNull @Valid // private final Duration timeout; // @NotNull @Valid // private final Duration retryInterval; // @Valid // private final int retryAttempts; // // @JsonCreator // public AzureTableConfiguration(@JsonProperty("accountName") String accountName, // @JsonProperty("accountKey") String accountKey, // @JsonProperty("timeout")Duration timeout, // @JsonProperty("retryInterval") Duration retryInterval, // @JsonProperty("retryAttempts") int retryAttempts) { // this.retryInterval = checkNotNull(retryInterval, "retryInterval cannot be null"); // this.retryAttempts = retryAttempts; // this.timeout = checkNotNull(timeout, "timeout cannot be null"); // this.storageCredentialsAccountAndKey = // new StorageCredentialsAccountAndKey( // checkNotNull(accountName, "accountName cannot be null"), // checkNotNull(accountKey, "accountKey cannot be null")); // } // // @JsonIgnore // public StorageCredentialsAccountAndKey getStorageCredentialsAccountAndKey() { // return storageCredentialsAccountAndKey; // } // // public Duration getRetryInterval() { // return retryInterval; // } // // public int getRetryAttempts() { // return retryAttempts; // } // // public Duration getTimeout() { // return timeout; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // }
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.net.HostAndPort; import com.yammer.breakerbox.azure.AzureTableConfiguration; import com.yammer.breakerbox.jdbi.JdbiConfiguration; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import com.yammer.dropwizard.authenticator.LdapConfiguration; import com.yammer.tenacity.core.config.BreakerboxConfiguration; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.Configuration; import io.dropwizard.client.JerseyClientConfiguration; import org.hibernate.validator.valuehandling.UnwrapValidatedValue; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Optional;
package com.yammer.breakerbox.service.config; public class BreakerboxServiceConfiguration extends Configuration { @NotNull @UnwrapValidatedValue(false) @Valid
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/AzureTableConfiguration.java // public class AzureTableConfiguration { // // @NotNull @Valid // private final StorageCredentialsAccountAndKey storageCredentialsAccountAndKey; // @NotNull @Valid // private final Duration timeout; // @NotNull @Valid // private final Duration retryInterval; // @Valid // private final int retryAttempts; // // @JsonCreator // public AzureTableConfiguration(@JsonProperty("accountName") String accountName, // @JsonProperty("accountKey") String accountKey, // @JsonProperty("timeout")Duration timeout, // @JsonProperty("retryInterval") Duration retryInterval, // @JsonProperty("retryAttempts") int retryAttempts) { // this.retryInterval = checkNotNull(retryInterval, "retryInterval cannot be null"); // this.retryAttempts = retryAttempts; // this.timeout = checkNotNull(timeout, "timeout cannot be null"); // this.storageCredentialsAccountAndKey = // new StorageCredentialsAccountAndKey( // checkNotNull(accountName, "accountName cannot be null"), // checkNotNull(accountKey, "accountKey cannot be null")); // } // // @JsonIgnore // public StorageCredentialsAccountAndKey getStorageCredentialsAccountAndKey() { // return storageCredentialsAccountAndKey; // } // // public Duration getRetryInterval() { // return retryInterval; // } // // public int getRetryAttempts() { // return retryAttempts; // } // // public Duration getTimeout() { // return timeout; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/config/BreakerboxServiceConfiguration.java import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.net.HostAndPort; import com.yammer.breakerbox.azure.AzureTableConfiguration; import com.yammer.breakerbox.jdbi.JdbiConfiguration; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import com.yammer.dropwizard.authenticator.LdapConfiguration; import com.yammer.tenacity.core.config.BreakerboxConfiguration; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.Configuration; import io.dropwizard.client.JerseyClientConfiguration; import org.hibernate.validator.valuehandling.UnwrapValidatedValue; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Optional; package com.yammer.breakerbox.service.config; public class BreakerboxServiceConfiguration extends Configuration { @NotNull @UnwrapValidatedValue(false) @Valid
private final Optional<AzureTableConfiguration> azure;
yammer/breakerbox
breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/KubernetesInstanceDiscoveryTest.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/KubernetesInstanceDiscovery.java // public class KubernetesInstanceDiscovery implements InstanceDiscovery { // // private static final Logger LOGGER = LoggerFactory.getLogger(KubernetesInstanceDiscovery.class); // // public static final String PORT_ANNOTATION_KEY = "breakerbox-port"; // public static final String POD_HASH_LABEL_KEY = "pod-template-hash"; // // private final KubernetesClient client; // // public KubernetesInstanceDiscovery() { // this.client = new DefaultKubernetesClient(); // } // // public KubernetesInstanceDiscovery(KubernetesClient client) { // this.client = client; // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // LOGGER.info("Starting Kubernetes instance discovery using master URL: {}", client.getMasterUrl()); // return client.pods().inAnyNamespace() // .list() // .getItems().stream() // .filter(pod -> pod.getMetadata().getAnnotations() != null) // Ignore pods without annotations // .filter(pod -> pod.getMetadata().getAnnotations().containsKey(PORT_ANNOTATION_KEY)) // .map(pod -> { // String portString = pod.getMetadata().getAnnotations().get(PORT_ANNOTATION_KEY); // if (!Pattern.compile("^[0-9]{2,5}$").matcher(portString).matches()) { // LOGGER.warn("Invalid port annotation for pod '{}': {}", pod.getMetadata().getName(), portString); // return null; // } else { // String host = String.format("%s:%s", pod.getStatus().getPodIP(), portString); // boolean running = pod.getStatus().getPhase().equals("Running"); // LOGGER.info("Found Kubernetes Pod {} at address {}", pod.getMetadata().getName(), host); // return new Instance(host, extractClusterNameFor(pod), running); // } // }) // .filter(Objects::nonNull) // .collect(Collectors.toList()); // } // // private static String extractClusterNameFor(Pod pod) { // String podBaseName = pod.getMetadata().getGenerateName(); // // Remove auto-generated hashes, if there are any // if (pod.getMetadata().getLabels() != null && pod.getMetadata().getLabels().containsKey(POD_HASH_LABEL_KEY)) { // String hash = pod.getMetadata().getLabels().get(POD_HASH_LABEL_KEY); // podBaseName = podBaseName.replace(hash + "-", ""); // } // // Pod's base names always end with a '-', remove it // podBaseName = podBaseName.substring(0, podBaseName.length()-1); // return String.format("%s-%s", pod.getMetadata().getNamespace(), podBaseName); // } // }
import com.google.common.collect.Lists; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.KubernetesInstanceDiscovery; import io.fabric8.kubernetes.api.model.*; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.dsl.ClientMixedOperation; import io.fabric8.kubernetes.client.dsl.ClientPodResource; import org.assertj.core.util.Maps; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.regex.Pattern; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.stub;
package com.yammer.breakerbox.turbine.tests; @RunWith(MockitoJUnitRunner.class) public class KubernetesInstanceDiscoveryTest { @Mock DefaultKubernetesClient client; @Mock ClientMixedOperation<Pod, PodList, DoneablePod, ClientPodResource<Pod, DoneablePod>> podsOperation; @Mock ClientMixedOperation<Pod, PodList, DoneablePod, ClientPodResource<Pod, DoneablePod>> podsAnyNsOperation; @Mock PodList podList;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/KubernetesInstanceDiscovery.java // public class KubernetesInstanceDiscovery implements InstanceDiscovery { // // private static final Logger LOGGER = LoggerFactory.getLogger(KubernetesInstanceDiscovery.class); // // public static final String PORT_ANNOTATION_KEY = "breakerbox-port"; // public static final String POD_HASH_LABEL_KEY = "pod-template-hash"; // // private final KubernetesClient client; // // public KubernetesInstanceDiscovery() { // this.client = new DefaultKubernetesClient(); // } // // public KubernetesInstanceDiscovery(KubernetesClient client) { // this.client = client; // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // LOGGER.info("Starting Kubernetes instance discovery using master URL: {}", client.getMasterUrl()); // return client.pods().inAnyNamespace() // .list() // .getItems().stream() // .filter(pod -> pod.getMetadata().getAnnotations() != null) // Ignore pods without annotations // .filter(pod -> pod.getMetadata().getAnnotations().containsKey(PORT_ANNOTATION_KEY)) // .map(pod -> { // String portString = pod.getMetadata().getAnnotations().get(PORT_ANNOTATION_KEY); // if (!Pattern.compile("^[0-9]{2,5}$").matcher(portString).matches()) { // LOGGER.warn("Invalid port annotation for pod '{}': {}", pod.getMetadata().getName(), portString); // return null; // } else { // String host = String.format("%s:%s", pod.getStatus().getPodIP(), portString); // boolean running = pod.getStatus().getPhase().equals("Running"); // LOGGER.info("Found Kubernetes Pod {} at address {}", pod.getMetadata().getName(), host); // return new Instance(host, extractClusterNameFor(pod), running); // } // }) // .filter(Objects::nonNull) // .collect(Collectors.toList()); // } // // private static String extractClusterNameFor(Pod pod) { // String podBaseName = pod.getMetadata().getGenerateName(); // // Remove auto-generated hashes, if there are any // if (pod.getMetadata().getLabels() != null && pod.getMetadata().getLabels().containsKey(POD_HASH_LABEL_KEY)) { // String hash = pod.getMetadata().getLabels().get(POD_HASH_LABEL_KEY); // podBaseName = podBaseName.replace(hash + "-", ""); // } // // Pod's base names always end with a '-', remove it // podBaseName = podBaseName.substring(0, podBaseName.length()-1); // return String.format("%s-%s", pod.getMetadata().getNamespace(), podBaseName); // } // } // Path: breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/KubernetesInstanceDiscoveryTest.java import com.google.common.collect.Lists; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.KubernetesInstanceDiscovery; import io.fabric8.kubernetes.api.model.*; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.dsl.ClientMixedOperation; import io.fabric8.kubernetes.client.dsl.ClientPodResource; import org.assertj.core.util.Maps; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.regex.Pattern; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.stub; package com.yammer.breakerbox.turbine.tests; @RunWith(MockitoJUnitRunner.class) public class KubernetesInstanceDiscoveryTest { @Mock DefaultKubernetesClient client; @Mock ClientMixedOperation<Pod, PodList, DoneablePod, ClientPodResource<Pod, DoneablePod>> podsOperation; @Mock ClientMixedOperation<Pod, PodList, DoneablePod, ClientPodResource<Pod, DoneablePod>> podsAnyNsOperation; @Mock PodList podList;
private KubernetesInstanceDiscovery discovery;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // }
import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Objects;
package com.yammer.breakerbox.turbine.client; public class RancherClient { private final Invocation.Builder builder;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Objects; package com.yammer.breakerbox.turbine.client; public class RancherClient { private final Invocation.Builder builder;
private final RancherInstanceConfiguration instanceConfiguration;
yammer/breakerbox
breakerbox-store/src/main/java/com/yammer/breakerbox/store/BreakerboxStore.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.codahale.metrics.Timer; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import io.dropwizard.setup.Environment; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; import static com.codahale.metrics.MetricRegistry.name;
package com.yammer.breakerbox.store; public abstract class BreakerboxStore { protected final Timer listServices; protected final Timer listService; protected final Timer dependencyConfigs; @SuppressWarnings("unused") protected <StoreConfiguration> BreakerboxStore(StoreConfiguration storeConfiguration, Environment environment) { this.listServices = environment.metrics().timer(name(BreakerboxStore.class, "list-services")); this.listService = environment.metrics().timer(name(BreakerboxStore.class, "list-service")); this.dependencyConfigs = environment.metrics().timer(name(BreakerboxStore.class, "latest-dependency-config")); } public abstract boolean initialize() throws Exception;
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/BreakerboxStore.java import com.codahale.metrics.Timer; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import io.dropwizard.setup.Environment; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; import static com.codahale.metrics.MetricRegistry.name; package com.yammer.breakerbox.store; public abstract class BreakerboxStore { protected final Timer listServices; protected final Timer listService; protected final Timer dependencyConfigs; @SuppressWarnings("unused") protected <StoreConfiguration> BreakerboxStore(StoreConfiguration storeConfiguration, Environment environment) { this.listServices = environment.metrics().timer(name(BreakerboxStore.class, "list-services")); this.listService = environment.metrics().timer(name(BreakerboxStore.class, "list-service")); this.dependencyConfigs = environment.metrics().timer(name(BreakerboxStore.class, "latest-dependency-config")); } public abstract boolean initialize() throws Exception;
public abstract boolean store(DependencyModel dependencyModel);
yammer/breakerbox
breakerbox-store/src/main/java/com/yammer/breakerbox/store/BreakerboxStore.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.codahale.metrics.Timer; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import io.dropwizard.setup.Environment; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; import static com.codahale.metrics.MetricRegistry.name;
package com.yammer.breakerbox.store; public abstract class BreakerboxStore { protected final Timer listServices; protected final Timer listService; protected final Timer dependencyConfigs; @SuppressWarnings("unused") protected <StoreConfiguration> BreakerboxStore(StoreConfiguration storeConfiguration, Environment environment) { this.listServices = environment.metrics().timer(name(BreakerboxStore.class, "list-services")); this.listService = environment.metrics().timer(name(BreakerboxStore.class, "list-service")); this.dependencyConfigs = environment.metrics().timer(name(BreakerboxStore.class, "latest-dependency-config")); } public abstract boolean initialize() throws Exception; public abstract boolean store(DependencyModel dependencyModel);
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/BreakerboxStore.java import com.codahale.metrics.Timer; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import io.dropwizard.setup.Environment; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; import static com.codahale.metrics.MetricRegistry.name; package com.yammer.breakerbox.store; public abstract class BreakerboxStore { protected final Timer listServices; protected final Timer listService; protected final Timer dependencyConfigs; @SuppressWarnings("unused") protected <StoreConfiguration> BreakerboxStore(StoreConfiguration storeConfiguration, Environment environment) { this.listServices = environment.metrics().timer(name(BreakerboxStore.class, "list-services")); this.listService = environment.metrics().timer(name(BreakerboxStore.class, "list-service")); this.dependencyConfigs = environment.metrics().timer(name(BreakerboxStore.class, "latest-dependency-config")); } public abstract boolean initialize() throws Exception; public abstract boolean store(DependencyModel dependencyModel);
public abstract boolean store(ServiceModel serviceModel);
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/ServiceDB.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.ServiceModel; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.ServiceModelMapper.class) public interface ServiceDB { @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/ServiceDB.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.ServiceModel; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.ServiceModelMapper.class) public interface ServiceDB { @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId")
ServiceModel find(@BindBean("service") ServiceModel service);
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/ServiceDB.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.ServiceModel; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.ServiceModelMapper.class) public interface ServiceDB { @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId") ServiceModel find(@BindBean("service") ServiceModel service); @SqlUpdate("insert into service (name, dependency) values (:service.serviceId, :service.dependencyId)") int insert(@BindBean("service") ServiceModel service); @SqlUpdate("delete from service where name = :service.serviceId and dependency = :service.dependencyId") int delete(@BindBean("service") ServiceModel serviceModel); @SqlQuery("select * from service") ImmutableList<ServiceModel> all(); @SqlQuery("select * from service where name = :serviceId.id")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/ServiceDB.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.ServiceModel; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.ServiceModelMapper.class) public interface ServiceDB { @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId") ServiceModel find(@BindBean("service") ServiceModel service); @SqlUpdate("insert into service (name, dependency) values (:service.serviceId, :service.dependencyId)") int insert(@BindBean("service") ServiceModel service); @SqlUpdate("delete from service where name = :service.serviceId and dependency = :service.dependencyId") int delete(@BindBean("service") ServiceModel serviceModel); @SqlQuery("select * from service") ImmutableList<ServiceModel> all(); @SqlQuery("select * from service where name = :serviceId.id")
ImmutableList<ServiceModel> all(@BindBean("serviceId") ServiceId serviceId);
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityConfigurationFetcher.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/TurbineTenacityClient.java // public interface TurbineTenacityClient { // Optional<Collection<String>> getTenacityPropertyKeys(Instance instance); // // Optional<TenacityConfiguration> getTenacityConfiguration(Instance instance, TenacityPropertyKey key); // // Optional<Collection<CircuitBreaker>> getCircuitBreakers(Instance instance); // // Optional<CircuitBreaker> getCircuitBreaker(Instance instance, TenacityPropertyKey key); // // Optional<CircuitBreaker> modifyCircuitBreaker(Instance instance, // TenacityPropertyKey key, // CircuitBreaker.State state); // // static URI toUri(Instance instance) { // final String rawHostname = instance.getHostname().trim(); // if (rawHostname.startsWith("http")) { // return URI.create(rawHostname); // } else { // return URI.create("http://" + rawHostname); // } // } // }
import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.client.TurbineTenacityClient; import com.yammer.tenacity.core.TenacityCommand; import com.yammer.tenacity.core.config.TenacityConfiguration; import com.yammer.tenacity.core.properties.TenacityPropertyKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Objects; import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.google.common.base.Preconditions.checkNotNull;
package com.yammer.breakerbox.service.tenacity; public class TenacityConfigurationFetcher extends TenacityCommand<Optional<TenacityConfiguration>> { public static class Factory {
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/TurbineTenacityClient.java // public interface TurbineTenacityClient { // Optional<Collection<String>> getTenacityPropertyKeys(Instance instance); // // Optional<TenacityConfiguration> getTenacityConfiguration(Instance instance, TenacityPropertyKey key); // // Optional<Collection<CircuitBreaker>> getCircuitBreakers(Instance instance); // // Optional<CircuitBreaker> getCircuitBreaker(Instance instance, TenacityPropertyKey key); // // Optional<CircuitBreaker> modifyCircuitBreaker(Instance instance, // TenacityPropertyKey key, // CircuitBreaker.State state); // // static URI toUri(Instance instance) { // final String rawHostname = instance.getHostname().trim(); // if (rawHostname.startsWith("http")) { // return URI.create(rawHostname); // } else { // return URI.create("http://" + rawHostname); // } // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityConfigurationFetcher.java import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.client.TurbineTenacityClient; import com.yammer.tenacity.core.TenacityCommand; import com.yammer.tenacity.core.config.TenacityConfiguration; import com.yammer.tenacity.core.properties.TenacityPropertyKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Objects; import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.google.common.base.Preconditions.checkNotNull; package com.yammer.breakerbox.service.tenacity; public class TenacityConfigurationFetcher extends TenacityCommand<Optional<TenacityConfiguration>> { public static class Factory {
private final TurbineTenacityClient client;
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/Mappers.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.joda.time.DateTime; import org.skife.jdbi.v2.StatementContext; import org.skife.jdbi.v2.tweak.ResultSetMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Optional; import java.util.Set;
package com.yammer.breakerbox.jdbi; public class Mappers { public static class ServiceModelMapper implements ResultSetMapper<ServiceModel> { @Override public ServiceModel map(int index, ResultSet r, StatementContext ctx) throws SQLException {
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/Mappers.java import com.fasterxml.jackson.databind.ObjectMapper; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.joda.time.DateTime; import org.skife.jdbi.v2.StatementContext; import org.skife.jdbi.v2.tweak.ResultSetMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Optional; import java.util.Set; package com.yammer.breakerbox.jdbi; public class Mappers { public static class ServiceModelMapper implements ResultSetMapper<ServiceModel> { @Override public ServiceModel map(int index, ResultSet r, StatementContext ctx) throws SQLException {
return new ServiceModel(ServiceId.from(r.getString("name")), DependencyId.from(r.getString("dependency")));
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/Mappers.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.joda.time.DateTime; import org.skife.jdbi.v2.StatementContext; import org.skife.jdbi.v2.tweak.ResultSetMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Optional; import java.util.Set;
package com.yammer.breakerbox.jdbi; public class Mappers { public static class ServiceModelMapper implements ResultSetMapper<ServiceModel> { @Override public ServiceModel map(int index, ResultSet r, StatementContext ctx) throws SQLException {
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/Mappers.java import com.fasterxml.jackson.databind.ObjectMapper; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.joda.time.DateTime; import org.skife.jdbi.v2.StatementContext; import org.skife.jdbi.v2.tweak.ResultSetMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Optional; import java.util.Set; package com.yammer.breakerbox.jdbi; public class Mappers { public static class ServiceModelMapper implements ResultSetMapper<ServiceModel> { @Override public ServiceModel map(int index, ResultSet r, StatementContext ctx) throws SQLException {
return new ServiceModel(ServiceId.from(r.getString("name")), DependencyId.from(r.getString("dependency")));
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/Entities.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional;
package com.yammer.breakerbox.azure.model; public class Entities { private Entities() {}
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/Entities.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; package com.yammer.breakerbox.azure.model; public class Entities { private Entities() {}
public static Optional<ServiceModel> toServiceModel(Optional<ServiceEntity> serviceEntity) {
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/Entities.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional;
package com.yammer.breakerbox.azure.model; public class Entities { private Entities() {} public static Optional<ServiceModel> toServiceModel(Optional<ServiceEntity> serviceEntity) { return serviceEntity.map(Entities::toModel); } public static ServiceModel toModel(ServiceEntity serviceEntity) { return new ServiceModel(serviceEntity.getServiceId(), serviceEntity.getDependencyId()); } public static ServiceEntity from(ServiceModel serviceModel) { return ServiceEntity.build(serviceModel.getServiceId(), serviceModel.getDependencyId()); }
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java // public class ServiceModel { // private final ServiceId serviceId; // private final DependencyId dependencyId; // // public ServiceModel(ServiceId serviceId, DependencyId dependencyId) { // this.serviceId = serviceId; // this.dependencyId = dependencyId; // } // // public ServiceId getServiceId() { // return serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // @Override // public int hashCode() { // return Objects.hash(serviceId, dependencyId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceModel other = (ServiceModel) obj; // return Objects.equals(this.serviceId, other.serviceId) // && Objects.equals(this.dependencyId, other.dependencyId); // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/Entities.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.model.DependencyModel; import com.yammer.breakerbox.store.model.ServiceModel; import org.joda.time.DateTime; import java.util.Collection; import java.util.Optional; package com.yammer.breakerbox.azure.model; public class Entities { private Entities() {} public static Optional<ServiceModel> toServiceModel(Optional<ServiceEntity> serviceEntity) { return serviceEntity.map(Entities::toModel); } public static ServiceModel toModel(ServiceEntity serviceEntity) { return new ServiceModel(serviceEntity.getServiceId(), serviceEntity.getDependencyId()); } public static ServiceEntity from(ServiceModel serviceModel) { return ServiceEntity.build(serviceModel.getServiceId(), serviceModel.getDependencyId()); }
public static Optional<DependencyModel> toDependencyModel(Optional<DependencyEntity> dependencyEntity) {
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/YamlInstanceConfiguration.java // public class YamlInstanceConfiguration { // // @JsonUnwrapped // @Valid // private ImmutableMap<String, Cluster> clusters = ImmutableMap.of( // "breakerbox", Cluster.withInstances(HostAndPort.fromParts("localhost", 8080)), // "production", Cluster.withClusters("breakerbox")); // // @NotNull // private String urlSuffix = TurbineInstanceDiscovery.DEFAULT_URL_SUFFIX; // // public ImmutableMap<String, Cluster> getClusters() { // return clusters; // } // // public void setClusters(ImmutableMap<String, Cluster> clusters) { // this.clusters = clusters; // } // // public Set<Instance> getAllInstances() { // final ImmutableSet.Builder<Instance> builder = ImmutableSet.builder(); // for (Map.Entry<String, Cluster> entry : clusters.entrySet()) { // final String clusterName = entry.getKey(); // addCluster(builder, entry.getValue(), clusterName, ImmutableSet.of(clusterName)); // } // return builder.build(); // } // // private void addCluster(ImmutableSet.Builder<Instance> acc, // Cluster cluster, // String clusterName, // ImmutableSet<String> visited) { // acc.addAll(cluster.getInstances().stream() // .map(hostAndPort -> { // final Instance instance = new Instance(hostAndPort.toString(), clusterName, true); // instance.getAttributes().put(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID, hostAndPort.toString()); // return instance; // }) // .collect(Collectors.toList())); // cluster.getClusters() // .stream() // .filter(name -> !visited.contains(name)) // .forEach(notVisitedClusterName -> // addCluster(acc, clusters.get(notVisitedClusterName), clusterName, // ImmutableSet.<String>builder().addAll(visited).add(notVisitedClusterName).build())); // } // // public String getUrlSuffix() { // return urlSuffix; // } // // public void setUrlSuffix(String urlSuffix) { // this.urlSuffix = urlSuffix; // } // // @Override // public int hashCode() { // return Objects.hash(clusters, urlSuffix); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final YamlInstanceConfiguration other = (YamlInstanceConfiguration) obj; // return Objects.equals(this.clusters, other.clusters) // && Objects.equals(this.urlSuffix, other.urlSuffix); // } // // @Override // public String toString() { // return "YamlInstanceConfiguration{" + // "clusters=" + clusters + // ", urlSuffix='" + urlSuffix + '\'' + // '}'; // } // // public static class Cluster { // @Valid // private Set<HostAndPort> instances = Collections.emptySet(); // private Set<String> clusters = Collections.emptySet(); // // public Cluster() { /* Jackson */ // } // // public Cluster(Set<HostAndPort> instances, Set<String> clusters) { // this.instances = instances; // this.clusters = clusters; // } // // public Set<HostAndPort> getInstances() { // return instances; // } // // public Set<String> getClusters() { // return clusters; // } // // public void setInstances(Set<HostAndPort> instances) { // this.instances = instances; // } // // public void setClusters(Set<String> clusters) { // this.clusters = clusters; // } // // public static Cluster withInstances(HostAndPort... hostAndPorts) { // return new Cluster(ImmutableSet.copyOf(hostAndPorts), Collections.emptySet()); // } // // public static Cluster withClusters(String... clusters) { // return new Cluster(Collections.emptySet(), ImmutableSet.copyOf(clusters)); // } // // @Override // public int hashCode() { // return Objects.hash(instances, clusters); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final Cluster other = (Cluster) obj; // return Objects.equals(this.instances, other.instances) // && Objects.equals(this.clusters, other.clusters); // } // // @Override // public String toString() { // return "Cluster{" + // "instances=" + instances + // ", clusters=" + clusters + // '}'; // } // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.config.YamlInstanceConfiguration; import io.dropwizard.configuration.ConfigurationFactory; import io.dropwizard.configuration.YamlConfigurationFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validator; import java.nio.file.Path; import java.util.Collection; import java.util.Optional;
package com.yammer.breakerbox.turbine; public class YamlInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); private final Path path;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/YamlInstanceConfiguration.java // public class YamlInstanceConfiguration { // // @JsonUnwrapped // @Valid // private ImmutableMap<String, Cluster> clusters = ImmutableMap.of( // "breakerbox", Cluster.withInstances(HostAndPort.fromParts("localhost", 8080)), // "production", Cluster.withClusters("breakerbox")); // // @NotNull // private String urlSuffix = TurbineInstanceDiscovery.DEFAULT_URL_SUFFIX; // // public ImmutableMap<String, Cluster> getClusters() { // return clusters; // } // // public void setClusters(ImmutableMap<String, Cluster> clusters) { // this.clusters = clusters; // } // // public Set<Instance> getAllInstances() { // final ImmutableSet.Builder<Instance> builder = ImmutableSet.builder(); // for (Map.Entry<String, Cluster> entry : clusters.entrySet()) { // final String clusterName = entry.getKey(); // addCluster(builder, entry.getValue(), clusterName, ImmutableSet.of(clusterName)); // } // return builder.build(); // } // // private void addCluster(ImmutableSet.Builder<Instance> acc, // Cluster cluster, // String clusterName, // ImmutableSet<String> visited) { // acc.addAll(cluster.getInstances().stream() // .map(hostAndPort -> { // final Instance instance = new Instance(hostAndPort.toString(), clusterName, true); // instance.getAttributes().put(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID, hostAndPort.toString()); // return instance; // }) // .collect(Collectors.toList())); // cluster.getClusters() // .stream() // .filter(name -> !visited.contains(name)) // .forEach(notVisitedClusterName -> // addCluster(acc, clusters.get(notVisitedClusterName), clusterName, // ImmutableSet.<String>builder().addAll(visited).add(notVisitedClusterName).build())); // } // // public String getUrlSuffix() { // return urlSuffix; // } // // public void setUrlSuffix(String urlSuffix) { // this.urlSuffix = urlSuffix; // } // // @Override // public int hashCode() { // return Objects.hash(clusters, urlSuffix); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final YamlInstanceConfiguration other = (YamlInstanceConfiguration) obj; // return Objects.equals(this.clusters, other.clusters) // && Objects.equals(this.urlSuffix, other.urlSuffix); // } // // @Override // public String toString() { // return "YamlInstanceConfiguration{" + // "clusters=" + clusters + // ", urlSuffix='" + urlSuffix + '\'' + // '}'; // } // // public static class Cluster { // @Valid // private Set<HostAndPort> instances = Collections.emptySet(); // private Set<String> clusters = Collections.emptySet(); // // public Cluster() { /* Jackson */ // } // // public Cluster(Set<HostAndPort> instances, Set<String> clusters) { // this.instances = instances; // this.clusters = clusters; // } // // public Set<HostAndPort> getInstances() { // return instances; // } // // public Set<String> getClusters() { // return clusters; // } // // public void setInstances(Set<HostAndPort> instances) { // this.instances = instances; // } // // public void setClusters(Set<String> clusters) { // this.clusters = clusters; // } // // public static Cluster withInstances(HostAndPort... hostAndPorts) { // return new Cluster(ImmutableSet.copyOf(hostAndPorts), Collections.emptySet()); // } // // public static Cluster withClusters(String... clusters) { // return new Cluster(Collections.emptySet(), ImmutableSet.copyOf(clusters)); // } // // @Override // public int hashCode() { // return Objects.hash(instances, clusters); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final Cluster other = (Cluster) obj; // return Objects.equals(this.instances, other.instances) // && Objects.equals(this.clusters, other.clusters); // } // // @Override // public String toString() { // return "Cluster{" + // "instances=" + instances + // ", clusters=" + clusters + // '}'; // } // } // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.config.YamlInstanceConfiguration; import io.dropwizard.configuration.ConfigurationFactory; import io.dropwizard.configuration.YamlConfigurationFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validator; import java.nio.file.Path; import java.util.Collection; import java.util.Optional; package com.yammer.breakerbox.turbine; public class YamlInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); private final Path path;
private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory;
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/DependencyEntity.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.util.Optional; import java.util.Set;
package com.yammer.breakerbox.azure.model; /** * Bean to represent the Dependency table. * This is for looking up time-based configurations on a per-key basis. It is assumed that you know which * Dependency Key you wish to use before accessing this table. */ public class DependencyEntity extends TableType implements TableKey { private static final ObjectMapper OBJECTMAPPER = Jackson.newObjectMapper(); private static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private String tenacityConfigurationAsString; private String user; private String serviceName;
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/DependencyEntity.java import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.util.Optional; import java.util.Set; package com.yammer.breakerbox.azure.model; /** * Bean to represent the Dependency table. * This is for looking up time-based configurations on a per-key basis. It is assumed that you know which * Dependency Key you wish to use before accessing this table. */ public class DependencyEntity extends TableType implements TableKey { private static final ObjectMapper OBJECTMAPPER = Jackson.newObjectMapper(); private static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private String tenacityConfigurationAsString; private String user; private String serviceName;
private DependencyEntity(DependencyId dependencyId,
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/DependencyEntity.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // }
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.util.Optional; import java.util.Set;
package com.yammer.breakerbox.azure.model; /** * Bean to represent the Dependency table. * This is for looking up time-based configurations on a per-key basis. It is assumed that you know which * Dependency Key you wish to use before accessing this table. */ public class DependencyEntity extends TableType implements TableKey { private static final ObjectMapper OBJECTMAPPER = Jackson.newObjectMapper(); private static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private String tenacityConfigurationAsString; private String user; private String serviceName; private DependencyEntity(DependencyId dependencyId, long timeStamp, String userName, String configuration,
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/model/DependencyEntity.java import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.storage.table.TableServiceEntity; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.tenacity.core.config.TenacityConfiguration; import io.dropwizard.jackson.Jackson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.validation.Validation; import javax.validation.Validator; import java.util.Optional; import java.util.Set; package com.yammer.breakerbox.azure.model; /** * Bean to represent the Dependency table. * This is for looking up time-based configurations on a per-key basis. It is assumed that you know which * Dependency Key you wish to use before accessing this table. */ public class DependencyEntity extends TableType implements TableKey { private static final ObjectMapper OBJECTMAPPER = Jackson.newObjectMapper(); private static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator(); private static final Logger LOGGER = LoggerFactory.getLogger(ServiceEntity.class); private String tenacityConfigurationAsString; private String user; private String serviceName; private DependencyEntity(DependencyId dependencyId, long timeStamp, String userName, String configuration,
ServiceId serviceId) {
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // }
import com.google.common.collect.ImmutableList; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.table.*; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.net.URISyntaxException; import java.util.Optional; import static com.google.common.base.Preconditions.checkNotNull;
package com.yammer.breakerbox.azure; public class TableClient { private final CloudTableClient cloudTableClient; private static final Logger LOG = LoggerFactory.getLogger(TableClient.class); public TableClient(CloudTableClient cloudTableClient) { this.cloudTableClient = checkNotNull(cloudTableClient, "cloudTableClient cannot be null"); } private CloudTable tableRefrence(AzureTableName table) { try { return cloudTableClient.getTableReference(table.toString()); } catch (URISyntaxException e) { LOG.warn("URI exception creating table: {},", table, e); } catch (StorageException e) { LOG.warn("Error generating TableClient: {}", table, e); } throw new IllegalStateException("Could not create table: " + table); } public void create(AzureTableName table) { try { tableRefrence(table).createIfNotExists(); return; } catch (StorageException e) { LOG.warn("Error creating table: {}", table, e); } throw new IllegalStateException("Could not create table: " + table); }
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java import com.google.common.collect.ImmutableList; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.table.*; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.net.URISyntaxException; import java.util.Optional; import static com.google.common.base.Preconditions.checkNotNull; package com.yammer.breakerbox.azure; public class TableClient { private final CloudTableClient cloudTableClient; private static final Logger LOG = LoggerFactory.getLogger(TableClient.class); public TableClient(CloudTableClient cloudTableClient) { this.cloudTableClient = checkNotNull(cloudTableClient, "cloudTableClient cannot be null"); } private CloudTable tableRefrence(AzureTableName table) { try { return cloudTableClient.getTableReference(table.toString()); } catch (URISyntaxException e) { LOG.warn("URI exception creating table: {},", table, e); } catch (StorageException e) { LOG.warn("Error generating TableClient: {}", table, e); } throw new IllegalStateException("Could not create table: " + table); } public void create(AzureTableName table) { try { tableRefrence(table).createIfNotExists(); return; } catch (StorageException e) { LOG.warn("Error creating table: {}", table, e); } throw new IllegalStateException("Could not create table: " + table); }
public boolean insert(TableType entity) {
yammer/breakerbox
breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // }
import com.google.common.collect.ImmutableList; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.table.*; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.net.URISyntaxException; import java.util.Optional; import static com.google.common.base.Preconditions.checkNotNull;
} public boolean insert(TableType entity) { try { return tableRefrence(entity.getAzureTableName()) .execute(TableOperation.insert(entity)) .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); } catch (StorageException e) { LOG.warn("Error performing operation on Storage service", e); } throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName()); } public boolean insertOrReplace(TableType entity) { try { final TableResult tableResult = tableRefrence(entity.getAzureTableName()) .execute(TableOperation.insertOrReplace(entity)); switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) { case CREATED: case NO_CONTENT: return true; default: return false; } } catch (StorageException e) { LOG.warn("Error performing operation on Storage service", e); } throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName()); }
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java // public interface TableKey { // String getRowKey(); // String getPartitionKey(); // Class<? extends TableServiceEntity> getEntityClass(); // AzureTableName getTable(); // } // // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java // public abstract class TableType extends TableServiceEntity { // protected final AzureTableName azureTableName; // // protected TableType(AzureTableName azureTableName) { // this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null"); // } // // public AzureTableName getAzureTableName() { // return azureTableName; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof TableType)) return false; // // TableType that = (TableType) o; // // if (azureTableName != that.azureTableName) return false; // if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false; // if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = azureTableName.hashCode(); // result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0); // result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0); // return result; // } // } // Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java import com.google.common.collect.ImmutableList; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.table.*; import com.yammer.breakerbox.azure.core.AzureTableName; import com.yammer.breakerbox.azure.core.TableKey; import com.yammer.breakerbox.azure.core.TableType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.net.URISyntaxException; import java.util.Optional; import static com.google.common.base.Preconditions.checkNotNull; } public boolean insert(TableType entity) { try { return tableRefrence(entity.getAzureTableName()) .execute(TableOperation.insert(entity)) .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); } catch (StorageException e) { LOG.warn("Error performing operation on Storage service", e); } throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName()); } public boolean insertOrReplace(TableType entity) { try { final TableResult tableResult = tableRefrence(entity.getAzureTableName()) .execute(TableOperation.insertOrReplace(entity)); switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) { case CREATED: case NO_CONTENT: return true; default: return false; } } catch (StorageException e) { LOG.warn("Error performing operation on Storage service", e); } throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName()); }
public <EntityType extends TableServiceEntity> Optional<EntityType> retrieve(TableKey tableKey) {
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // }
import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors;
package com.yammer.breakerbox.service.core; public class Instances { private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); public static Collection<Instance> instances() { try { return PluginsFactory.getInstanceDiscovery().getInstanceList(); } catch (Exception err) { LOGGER.warn("Could not fetch clusters dynamically", err); } return ImmutableList.of(); } public static Collection<String> clusters() { return instances() .stream() .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { return instances() .stream() .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); }
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; package com.yammer.breakerbox.service.core; public class Instances { private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); public static Collection<Instance> instances() { try { return PluginsFactory.getInstanceDiscovery().getInstanceList(); } catch (Exception err) { LOGGER.warn("Could not fetch clusters dynamically", err); } return ImmutableList.of(); } public static Collection<String> clusters() { return instances() .stream() .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { return instances() .stream() .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); }
public static Collection<Instance> instances(ServiceId serviceId) {
yammer/breakerbox
breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // }
import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors;
return ImmutableList.of(); } public static Collection<String> clusters() { return instances() .stream() .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { return instances() .stream() .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<Instance> instances(ServiceId serviceId) { return instances() .stream() .filter((instance) -> instance.getCluster().equals(serviceId.getId())) .sorted() .collect(Collectors.toList()); } public static String toInstanceId(Instance instance) {
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // } // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java import com.google.common.collect.ImmutableList; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; return ImmutableList.of(); } public static Collection<String> clusters() { return instances() .stream() .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { return instances() .stream() .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) .map(Instance::getCluster) .sorted() .collect(Collectors.toCollection(TreeSet::new)); } public static Collection<Instance> instances(ServiceId serviceId) { return instances() .stream() .filter((instance) -> instance.getCluster().equals(serviceId.getId())) .sorted() .collect(Collectors.toList()); } public static String toInstanceId(Instance instance) {
return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID);
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/RancherInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java // public class RancherClient { // private final Invocation.Builder builder; // private final RancherInstanceConfiguration instanceConfiguration; // // public RancherClient(final RancherInstanceConfiguration instanceConfiguration) { // Objects.requireNonNull(instanceConfiguration); // this.instanceConfiguration = instanceConfiguration; // this.builder = createInvocationBuilder(); // } // // private Invocation.Builder createInvocationBuilder() { // Client client = ClientBuilder.newClient(); // WebTarget webTarget = client.target(createRancherServiceUrl()); // return webTarget.request().header("Authorization", getBasicAuthentication()); // } // // private String createRancherServiceUrl() { // String filterParameters = instanceConfiguration.getQueryString(); // String apiUrl = instanceConfiguration.getServiceApiUrl(); // String serviceUrl = apiUrl.charAt(apiUrl.length() - 1) == '?' ? apiUrl : apiUrl + "?"; // return serviceUrl.replaceAll("\\s", "") + filterParameters; // } // // // private String getBasicAuthentication() { // String token = instanceConfiguration.getAccessKey() + ":" + instanceConfiguration.getSecretKey(); // return "BASIC " + new String(Base64.getEncoder().encode(token.getBytes(StandardCharsets.UTF_8)), // StandardCharsets.UTF_8); // } // // public Response getServiceInstanceDetails() { // return builder.get(); // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // }
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.type.TypeFactory; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.RancherClient; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors;
package com.yammer.breakerbox.turbine; public class RancherInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(RancherInstanceDiscovery.class);
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java // public class RancherClient { // private final Invocation.Builder builder; // private final RancherInstanceConfiguration instanceConfiguration; // // public RancherClient(final RancherInstanceConfiguration instanceConfiguration) { // Objects.requireNonNull(instanceConfiguration); // this.instanceConfiguration = instanceConfiguration; // this.builder = createInvocationBuilder(); // } // // private Invocation.Builder createInvocationBuilder() { // Client client = ClientBuilder.newClient(); // WebTarget webTarget = client.target(createRancherServiceUrl()); // return webTarget.request().header("Authorization", getBasicAuthentication()); // } // // private String createRancherServiceUrl() { // String filterParameters = instanceConfiguration.getQueryString(); // String apiUrl = instanceConfiguration.getServiceApiUrl(); // String serviceUrl = apiUrl.charAt(apiUrl.length() - 1) == '?' ? apiUrl : apiUrl + "?"; // return serviceUrl.replaceAll("\\s", "") + filterParameters; // } // // // private String getBasicAuthentication() { // String token = instanceConfiguration.getAccessKey() + ":" + instanceConfiguration.getSecretKey(); // return "BASIC " + new String(Base64.getEncoder().encode(token.getBytes(StandardCharsets.UTF_8)), // StandardCharsets.UTF_8); // } // // public Response getServiceInstanceDetails() { // return builder.get(); // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/RancherInstanceDiscovery.java import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.type.TypeFactory; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.RancherClient; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; package com.yammer.breakerbox.turbine; public class RancherInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(RancherInstanceDiscovery.class);
private final RancherClient rancherClient;
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/RancherInstanceDiscovery.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java // public class RancherClient { // private final Invocation.Builder builder; // private final RancherInstanceConfiguration instanceConfiguration; // // public RancherClient(final RancherInstanceConfiguration instanceConfiguration) { // Objects.requireNonNull(instanceConfiguration); // this.instanceConfiguration = instanceConfiguration; // this.builder = createInvocationBuilder(); // } // // private Invocation.Builder createInvocationBuilder() { // Client client = ClientBuilder.newClient(); // WebTarget webTarget = client.target(createRancherServiceUrl()); // return webTarget.request().header("Authorization", getBasicAuthentication()); // } // // private String createRancherServiceUrl() { // String filterParameters = instanceConfiguration.getQueryString(); // String apiUrl = instanceConfiguration.getServiceApiUrl(); // String serviceUrl = apiUrl.charAt(apiUrl.length() - 1) == '?' ? apiUrl : apiUrl + "?"; // return serviceUrl.replaceAll("\\s", "") + filterParameters; // } // // // private String getBasicAuthentication() { // String token = instanceConfiguration.getAccessKey() + ":" + instanceConfiguration.getSecretKey(); // return "BASIC " + new String(Base64.getEncoder().encode(token.getBytes(StandardCharsets.UTF_8)), // StandardCharsets.UTF_8); // } // // public Response getServiceInstanceDetails() { // return builder.get(); // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // }
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.type.TypeFactory; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.RancherClient; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors;
package com.yammer.breakerbox.turbine; public class RancherInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(RancherInstanceDiscovery.class); private final RancherClient rancherClient; private final ObjectMapper mapper;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/RancherClient.java // public class RancherClient { // private final Invocation.Builder builder; // private final RancherInstanceConfiguration instanceConfiguration; // // public RancherClient(final RancherInstanceConfiguration instanceConfiguration) { // Objects.requireNonNull(instanceConfiguration); // this.instanceConfiguration = instanceConfiguration; // this.builder = createInvocationBuilder(); // } // // private Invocation.Builder createInvocationBuilder() { // Client client = ClientBuilder.newClient(); // WebTarget webTarget = client.target(createRancherServiceUrl()); // return webTarget.request().header("Authorization", getBasicAuthentication()); // } // // private String createRancherServiceUrl() { // String filterParameters = instanceConfiguration.getQueryString(); // String apiUrl = instanceConfiguration.getServiceApiUrl(); // String serviceUrl = apiUrl.charAt(apiUrl.length() - 1) == '?' ? apiUrl : apiUrl + "?"; // return serviceUrl.replaceAll("\\s", "") + filterParameters; // } // // // private String getBasicAuthentication() { // String token = instanceConfiguration.getAccessKey() + ":" + instanceConfiguration.getSecretKey(); // return "BASIC " + new String(Base64.getEncoder().encode(token.getBytes(StandardCharsets.UTF_8)), // StandardCharsets.UTF_8); // } // // public Response getServiceInstanceDetails() { // return builder.get(); // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/RancherInstanceConfiguration.java // public class RancherInstanceConfiguration { // @NotEmpty // private String serviceApiUrl; // @NotEmpty // private String accessKey; // @NotEmpty // private String secretKey; // @Nullable // private Map<String, String> parameters; // // public Map<String, String> getParameters() { // return parameters; // } // // public String getServiceApiUrl() { // return serviceApiUrl; // } // // public String getAccessKey() { // return accessKey; // } // // public String getSecretKey() { // return secretKey; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // RancherInstanceConfiguration that = (RancherInstanceConfiguration) o; // return serviceApiUrl.equals(that.serviceApiUrl) // && accessKey.equals(that.accessKey) // && secretKey.equals(that.secretKey) // && null != parameters ? parameters.equals(that.parameters) : null == that.parameters; // } // // @Override // public int hashCode() { // int result = serviceApiUrl.hashCode(); // result = 31 * result + accessKey.hashCode(); // result = 31 * result + secretKey.hashCode(); // if(null != parameters) { // result = 31 * result + parameters.hashCode(); // } // return result; // } // // @Override // public String toString() { // return "RancherInstanceConfiguration{" + // "serviceApiUrl='" + serviceApiUrl + '\'' + // ", accessKey='" + accessKey + '\'' + // ", secretKey='" + secretKey + '\'' + // ", parameters='" + getQueryString() + '\'' + // '}'; // } // // public String getQueryString() { // return null!=parameters ? parameters.keySet().stream().map(s -> s +"="+ parameters.get(s)).reduce((s, s2) -> s+"&"+s2).orElse("") : ""; // } // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/RancherInstanceDiscovery.java import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.type.TypeFactory; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.discovery.InstanceDiscovery; import com.yammer.breakerbox.turbine.client.RancherClient; import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; package com.yammer.breakerbox.turbine; public class RancherInstanceDiscovery implements InstanceDiscovery { private static final Logger LOGGER = LoggerFactory.getLogger(RancherInstanceDiscovery.class); private final RancherClient rancherClient; private final ObjectMapper mapper;
public RancherInstanceDiscovery(RancherInstanceConfiguration instanceConfiguration,
yammer/breakerbox
breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/YamlInstanceConfiguration.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // }
import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.net.HostAndPort; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors;
package com.yammer.breakerbox.turbine.config; public class YamlInstanceConfiguration { @JsonUnwrapped @Valid private ImmutableMap<String, Cluster> clusters = ImmutableMap.of( "breakerbox", Cluster.withInstances(HostAndPort.fromParts("localhost", 8080)), "production", Cluster.withClusters("breakerbox")); @NotNull
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java // public class TurbineInstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class); // public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id"; // public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream"; // // private TurbineInstanceDiscovery() {} // // public static void registerClusters(Collection<String> clusterNames) { // registerClusters(clusterNames, DEFAULT_URL_SUFFIX); // } // // public static void registerClusters(Collection<String> clusterNames, // String instanceUrlSuffix) { // final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance(); // configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG, // Joiner.on(',').join(clusterNames)); // configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix); // final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory(); // if (clusterMonitorFactory != null) { // try { // clusterMonitorFactory.initClusterMonitors(); // } catch (Exception err) { // LOGGER.error("Trouble initializing cluster monitors", err); // } // } // } // } // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/YamlInstanceConfiguration.java import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.net.HostAndPort; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; package com.yammer.breakerbox.turbine.config; public class YamlInstanceConfiguration { @JsonUnwrapped @Valid private ImmutableMap<String, Cluster> clusters = ImmutableMap.of( "breakerbox", Cluster.withInstances(HostAndPort.fromParts("localhost", 8080)), "production", Cluster.withClusters("breakerbox")); @NotNull
private String urlSuffix = TurbineInstanceDiscovery.DEFAULT_URL_SUFFIX;
yammer/breakerbox
breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock;
package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper();
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // Path: breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock; package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper();
private MarathonClient marathonClient = mock(MarathonClient.class);
yammer/breakerbox
breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock;
package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper(); private MarathonClient marathonClient = mock(MarathonClient.class);
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // Path: breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock; package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper(); private MarathonClient marathonClient = mock(MarathonClient.class);
private MarathonClientConfiguration marathonClientConfiguration;
yammer/breakerbox
breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // }
import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock;
package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper(); private MarathonClient marathonClient = mock(MarathonClient.class); private MarathonClientConfiguration marathonClientConfiguration;
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/MarathonInstanceDiscovery.java // public class MarathonInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(MarathonInstanceDiscovery.class); // private final ObjectMapper mapper; // private MarathonClient marathonClient; // private final List<MarathonClientConfiguration> marathonClientConfigurations; // private Map<MarathonClientConfiguration,Invocation.Builder> marathonClientConfigurationBuilderMap; // // public MarathonInstanceDiscovery(ObjectMapper mapper, List<MarathonClientConfiguration> marathonClientConfigurations) { // this.mapper = mapper; // this.marathonClientConfigurations = marathonClientConfigurations; // constructMarathonClientConfigurationBuilderMap(); // } // // private void constructMarathonClientConfigurationBuilderMap() { // marathonClientConfigurationBuilderMap = new HashMap<>(); // marathonClientConfigurations.parallelStream().forEach(marathonClientConfiguration -> { // marathonClient = new MarathonClient(marathonClientConfiguration); // Invocation.Builder builder = marathonClient.getServiceInstanceDetails(); // marathonClientConfigurationBuilderMap.put(marathonClientConfiguration,builder); // }); // // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // List<Instance> instances = new ArrayList<>(); // marathonClientConfigurationBuilderMap.entrySet().parallelStream().forEach(entry -> { // Response response = null; // try { // response = entry.getValue().get(); // if (response.getStatus() == HttpStatus.SC_OK) { // instances.addAll(createServiceInstanceList(response.readEntity(String.class), entry.getKey())); // } // } finally { // if (response != null) { // response.close(); // } // } // }); // return instances; // } // // public List<Instance> createServiceInstanceList(String marathonApiResponse,MarathonClientConfiguration marathonClientConfiguration) { // MarathonClientResponse marathonClientResponse = null; // try { // marathonClientResponse = mapper.readValue(marathonApiResponse, MarathonClientResponse.class); // } catch (IOException e) { // LOGGER.error("io exception",e); // } // if (marathonClientResponse != null && marathonClientResponse.getApp() != null) { // List<PortMapping> portMappingList = marathonClientResponse.getApp().getContainer().getDocker().getPortMappings(); // int portIndex = -1; // for (int i = 0; i < portMappingList.size(); i++) { // if (portMappingList.get(i).getContainerPort().equals(marathonClientConfiguration.getMarathonAppPort())) { // portIndex = i; // break; // } // } // if (portIndex < 0) { // LOGGER.error("marathon app port non present in port mapping"); // return Collections.emptyList(); // } // // List<Task> tasks = marathonClientResponse.getApp().getTasks(); // int finalPortIndex = portIndex; // return tasks.stream().map(task -> new Instance(task.getHost() + ":" + task.getPorts().get(finalPortIndex), marathonClientConfiguration.getCluster(), true)).collect(Collectors.toList()); // } else { // LOGGER.error("tasks not available for the given namespace"); // return Collections.emptyList(); // } // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/client/MarathonClient.java // public class MarathonClient { // // private MarathonClientConfiguration marathonClientConfiguration; // // public MarathonClient(MarathonClientConfiguration marathonClientConfiguration){ // this.marathonClientConfiguration = marathonClientConfiguration; // } // // public Invocation.Builder getServiceInstanceDetails() { // Client client = JerseyClientBuilder.newClient(); // WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); // return target.request(); // } // // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/config/MarathonClientConfiguration.java // public class MarathonClientConfiguration { // @NotEmpty // private String marathonApiUrl; // @NotEmpty // private String marathonAppNameSpace; // @NotEmpty // private Integer marathonAppPort; // // this is the custom clustername that you can have for the services cluster // @NotEmpty // private String cluster; // // public String getCluster() { return cluster; } // // public String getMarathonApiUrl() { // return marathonApiUrl; // } // // public String getMarathonAppNameSpace() { // return marathonAppNameSpace; // } // // public Integer getMarathonAppPort() { // return marathonAppPort; // } // // // public void setMarathonApiUrl(String marathonApiUrl) { // this.marathonApiUrl = marathonApiUrl; // } // // public void setMarathonAppNameSpace(String marathonAppNameSpace) { // this.marathonAppNameSpace = marathonAppNameSpace; // } // // public void setMarathonAppPort(Integer marathonAppPort) { // this.marathonAppPort = marathonAppPort; // } // // public void setCluster(String cluster) { // this.cluster = cluster; // } // } // Path: breakerbox-turbine/src/test/java/com/yammer/breakerbox/turbine/tests/MarathonInstanceDiscoveryTest.java import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.turbine.MarathonInstanceDiscovery; import com.yammer.breakerbox.turbine.client.MarathonClient; import com.yammer.breakerbox.turbine.config.MarathonClientConfiguration; import io.dropwizard.jackson.Jackson; import io.dropwizard.testing.FixtureHelpers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.List; import static org.mockito.Mockito.mock; package com.yammer.breakerbox.turbine.tests; /** * Created by supreeth.vp on 24/05/17. */ public class MarathonInstanceDiscoveryTest { private static final ObjectMapper MAPPER = Jackson.newObjectMapper(); private MarathonClient marathonClient = mock(MarathonClient.class); private MarathonClientConfiguration marathonClientConfiguration;
private MarathonInstanceDiscovery marathonInstanceDiscovery;
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis")
DependencyModel find(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp);
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis")
DependencyModel find(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp);
yammer/breakerbox
breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis") DependencyModel find(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp); @SqlUpdate("insert into dependency (name, timestamp, tenacity_configuration, username, service) values " + "(:dependency.dependencyId, :dependency.dateTime, :dependency.tenacityConfiguration," + " :dependency.user, :dependency.serviceId)") int insert(@BindBean("dependency") DependencyModel dependencyModel); @SqlUpdate("delete from dependency where name = :dependency.id and timestamp = :timestamp.millis") int delete(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp); @SqlQuery("select * from dependency where name = :dependency.id and service = :service.id order by timestamp desc limit 1")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/DependencyId.java // public class DependencyId implements TenacityPropertyKey { // private final String id; // // private DependencyId(String id) { // this.id = id.toUpperCase(); // } // // public String getId() { // return id; // } // // public static DependencyId from(String id) { // return new DependencyId(id); // } // // @Override // public String name() { // return id; // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyId other = (DependencyId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/DependencyModel.java // public class DependencyModel { // private final DependencyId dependencyId; // private final DateTime dateTime; // private final TenacityConfiguration tenacityConfiguration; // private final String user; // private final ServiceId serviceId; // // public DependencyModel(DependencyId dependencyId, // DateTime dateTime, // TenacityConfiguration tenacityConfiguration, // String user, // ServiceId serviceId) { // this.dependencyId = dependencyId; // this.dateTime = dateTime; // this.tenacityConfiguration = tenacityConfiguration; // this.user = user; // this.serviceId = serviceId; // } // // public DependencyId getDependencyId() { // return dependencyId; // } // // public DateTime getDateTime() { // return dateTime; // } // // public TenacityConfiguration getTenacityConfiguration() { // return tenacityConfiguration; // } // // public String getUser() { // return user; // } // // public ServiceId getServiceId() { // return serviceId; // } // // @Override // public int hashCode() { // return Objects.hash(dependencyId, dateTime, tenacityConfiguration, user, serviceId); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final DependencyModel other = (DependencyModel) obj; // return Objects.equals(this.dependencyId, other.dependencyId) // && Objects.equals(this.dateTime, other.dateTime) // && Objects.equals(this.tenacityConfiguration, other.tenacityConfiguration) // && Objects.equals(this.user, other.user) // && Objects.equals(this.serviceId, other.serviceId); // } // } // Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/DependencyDB.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.store.DependencyId; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.store.model.DependencyModel; import org.joda.time.DateTime; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; package com.yammer.breakerbox.jdbi; @RegisterMapper(Mappers.DependencyModelMapper.class) public interface DependencyDB { @SqlQuery("select * from dependency where name = :dependency.id and timestamp = :timestamp.millis") DependencyModel find(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp); @SqlUpdate("insert into dependency (name, timestamp, tenacity_configuration, username, service) values " + "(:dependency.dependencyId, :dependency.dateTime, :dependency.tenacityConfiguration," + " :dependency.user, :dependency.serviceId)") int insert(@BindBean("dependency") DependencyModel dependencyModel); @SqlUpdate("delete from dependency where name = :dependency.id and timestamp = :timestamp.millis") int delete(@BindBean("dependency") DependencyId dependencyId, @BindBean("timestamp") DateTime timestamp); @SqlQuery("select * from dependency where name = :dependency.id and service = :service.id order by timestamp desc limit 1")
DependencyModel findLatest(@BindBean("dependency") DependencyId dependencyId, @BindBean("service") ServiceId serviceId);
yammer/breakerbox
breakerbox-azure/src/test/java/com/yammer/breakerbox/azure/healthchecks/tests/TableClientHealthcheckTest.java
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java // public class TableClient { // // private final CloudTableClient cloudTableClient; // private static final Logger LOG = LoggerFactory.getLogger(TableClient.class); // // public TableClient(CloudTableClient cloudTableClient) { // this.cloudTableClient = checkNotNull(cloudTableClient, "cloudTableClient cannot be null"); // } // // private CloudTable tableRefrence(AzureTableName table) { // try { // return cloudTableClient.getTableReference(table.toString()); // } catch (URISyntaxException e) { // LOG.warn("URI exception creating table: {},", table, e); // } catch (StorageException e) { // LOG.warn("Error generating TableClient: {}", table, e); // } // throw new IllegalStateException("Could not create table: " + table); // } // // public void create(AzureTableName table) { // try { // tableRefrence(table).createIfNotExists(); // return; // } catch (StorageException e) { // LOG.warn("Error creating table: {}", table, e); // } // throw new IllegalStateException("Could not create table: " + table); // } // // public boolean insert(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.insert(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error performing operation on Storage service", e); // } // throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName()); // } // // public boolean insertOrReplace(TableType entity) { // try { // final TableResult tableResult = tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.insertOrReplace(entity)); // switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) { // case CREATED: // case NO_CONTENT: // return true; // default: // return false; // } // } catch (StorageException e) { // LOG.warn("Error performing operation on Storage service", e); // } // throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName()); // } // // public <EntityType extends TableServiceEntity> Optional<EntityType> retrieve(TableKey tableKey) { // try { // return Optional.ofNullable(tableRefrence(tableKey.getTable()) // .execute(TableOperation.retrieve(tableKey.getPartitionKey(), tableKey.getRowKey(), tableKey.getEntityClass())) // .getResultAsType()); // } catch (StorageException e) { // LOG.warn("Error retrieving entity from table: {}", tableKey.getTable(), e); // } // return Optional.empty(); // } // // public boolean update(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.replace(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error updating row in table: {}", entity.getAzureTableName(), e); // } // throw new IllegalStateException("Error updating data in table: " + entity.getAzureTableName()); // } // // public boolean destroy(AzureTableName azureTableName) { // try { // return tableRefrence(azureTableName).deleteIfExists(); // } catch (StorageException e) { // LOG.warn("Error deleting table from Azure", e); // } // throw new IllegalStateException("Unable to destroy table " + azureTableName); // } // // public boolean exists(AzureTableName azureTableName) { // try { // return tableRefrence(azureTableName).exists(); // } catch (StorageException e) { // LOG.warn("Error accessing azure table", e); // } // throw new IllegalStateException("Error verifying if table " + azureTableName + " exists"); // } // // public <EntityType extends TableEntity> ImmutableList<EntityType> search(AzureTableName azureTableName, // TableQuery<EntityType> query) { // return ImmutableList.copyOf(tableRefrence(azureTableName).execute(query)); // } // // public Iterable<String> listTables() { // return cloudTableClient.listTables(); // } // // public boolean remove(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.delete(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error updating row in table: {}", entity.getAzureTableName(), e); // } // throw new IllegalStateException("Error updating data in table: " + entity.getAzureTableName()); // } // }
import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.azure.TableClient; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.healthchecks.TableClientHealthcheck; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when;
package com.yammer.breakerbox.azure.healthchecks.tests; public class TableClientHealthcheckTest { @Test public void healthy() throws Exception {
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java // public class TableClient { // // private final CloudTableClient cloudTableClient; // private static final Logger LOG = LoggerFactory.getLogger(TableClient.class); // // public TableClient(CloudTableClient cloudTableClient) { // this.cloudTableClient = checkNotNull(cloudTableClient, "cloudTableClient cannot be null"); // } // // private CloudTable tableRefrence(AzureTableName table) { // try { // return cloudTableClient.getTableReference(table.toString()); // } catch (URISyntaxException e) { // LOG.warn("URI exception creating table: {},", table, e); // } catch (StorageException e) { // LOG.warn("Error generating TableClient: {}", table, e); // } // throw new IllegalStateException("Could not create table: " + table); // } // // public void create(AzureTableName table) { // try { // tableRefrence(table).createIfNotExists(); // return; // } catch (StorageException e) { // LOG.warn("Error creating table: {}", table, e); // } // throw new IllegalStateException("Could not create table: " + table); // } // // public boolean insert(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.insert(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error performing operation on Storage service", e); // } // throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName()); // } // // public boolean insertOrReplace(TableType entity) { // try { // final TableResult tableResult = tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.insertOrReplace(entity)); // switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) { // case CREATED: // case NO_CONTENT: // return true; // default: // return false; // } // } catch (StorageException e) { // LOG.warn("Error performing operation on Storage service", e); // } // throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName()); // } // // public <EntityType extends TableServiceEntity> Optional<EntityType> retrieve(TableKey tableKey) { // try { // return Optional.ofNullable(tableRefrence(tableKey.getTable()) // .execute(TableOperation.retrieve(tableKey.getPartitionKey(), tableKey.getRowKey(), tableKey.getEntityClass())) // .getResultAsType()); // } catch (StorageException e) { // LOG.warn("Error retrieving entity from table: {}", tableKey.getTable(), e); // } // return Optional.empty(); // } // // public boolean update(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.replace(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error updating row in table: {}", entity.getAzureTableName(), e); // } // throw new IllegalStateException("Error updating data in table: " + entity.getAzureTableName()); // } // // public boolean destroy(AzureTableName azureTableName) { // try { // return tableRefrence(azureTableName).deleteIfExists(); // } catch (StorageException e) { // LOG.warn("Error deleting table from Azure", e); // } // throw new IllegalStateException("Unable to destroy table " + azureTableName); // } // // public boolean exists(AzureTableName azureTableName) { // try { // return tableRefrence(azureTableName).exists(); // } catch (StorageException e) { // LOG.warn("Error accessing azure table", e); // } // throw new IllegalStateException("Error verifying if table " + azureTableName + " exists"); // } // // public <EntityType extends TableEntity> ImmutableList<EntityType> search(AzureTableName azureTableName, // TableQuery<EntityType> query) { // return ImmutableList.copyOf(tableRefrence(azureTableName).execute(query)); // } // // public Iterable<String> listTables() { // return cloudTableClient.listTables(); // } // // public boolean remove(TableType entity) { // try { // return tableRefrence(entity.getAzureTableName()) // .execute(TableOperation.delete(entity)) // .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode(); // } catch (StorageException e) { // LOG.warn("Error updating row in table: {}", entity.getAzureTableName(), e); // } // throw new IllegalStateException("Error updating data in table: " + entity.getAzureTableName()); // } // } // Path: breakerbox-azure/src/test/java/com/yammer/breakerbox/azure/healthchecks/tests/TableClientHealthcheckTest.java import com.google.common.collect.ImmutableList; import com.yammer.breakerbox.azure.TableClient; import com.yammer.breakerbox.azure.core.TableId; import com.yammer.breakerbox.azure.healthchecks.TableClientHealthcheck; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; package com.yammer.breakerbox.azure.healthchecks.tests; public class TableClientHealthcheckTest { @Test public void healthy() throws Exception {
final TableClient mockTableClient = mock(TableClient.class);
yammer/breakerbox
breakerbox-service/src/test/java/com/yammer/breakerbox/service/store/tests/TenacityPropertyKeysStoreTest.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java // public class TenacityPropertyKeysStore { // private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); // private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder // .newBuilder() // .expireAfterWrite(1, TimeUnit.MINUTES) // .build(); // private final TenacityPoller.Factory tenacityPollerFactory; // // public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) { // this.tenacityPollerFactory = tenacityPollerFactory; // } // // public Collection<String> getTenacityPropertyKeys(Instance instance) { // try { // return tenacityPropertyKeyCache.get(instance, () -> // tenacityPollerFactory.create(instance).execute().orElse(null)); // } catch (CacheLoader.InvalidCacheLoadException err) { // //null was returned // } catch (Exception err) { // LOGGER.warn("Unexpected exception", err); // } // return ImmutableList.of(); // } // // public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) { // return instances // .stream() // .map(this::getTenacityPropertyKeys) // .flatMap(Collection::stream) // .collect(Collectors.toSet()); // } // } // // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // }
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.junit.Test; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when;
package com.yammer.breakerbox.service.store.tests; public class TenacityPropertyKeysStoreTest { @Test public void tenacityPropertyKeysForUris() {
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java // public class TenacityPropertyKeysStore { // private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); // private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder // .newBuilder() // .expireAfterWrite(1, TimeUnit.MINUTES) // .build(); // private final TenacityPoller.Factory tenacityPollerFactory; // // public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) { // this.tenacityPollerFactory = tenacityPollerFactory; // } // // public Collection<String> getTenacityPropertyKeys(Instance instance) { // try { // return tenacityPropertyKeyCache.get(instance, () -> // tenacityPollerFactory.create(instance).execute().orElse(null)); // } catch (CacheLoader.InvalidCacheLoadException err) { // //null was returned // } catch (Exception err) { // LOGGER.warn("Unexpected exception", err); // } // return ImmutableList.of(); // } // // public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) { // return instances // .stream() // .map(this::getTenacityPropertyKeys) // .flatMap(Collection::stream) // .collect(Collectors.toSet()); // } // } // // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // } // Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/store/tests/TenacityPropertyKeysStoreTest.java import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.junit.Test; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; package com.yammer.breakerbox.service.store.tests; public class TenacityPropertyKeysStoreTest { @Test public void tenacityPropertyKeysForUris() {
final TenacityPoller.Factory mockFactory = mock(TenacityPoller.Factory.class);
yammer/breakerbox
breakerbox-service/src/test/java/com/yammer/breakerbox/service/store/tests/TenacityPropertyKeysStoreTest.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java // public class TenacityPropertyKeysStore { // private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); // private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder // .newBuilder() // .expireAfterWrite(1, TimeUnit.MINUTES) // .build(); // private final TenacityPoller.Factory tenacityPollerFactory; // // public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) { // this.tenacityPollerFactory = tenacityPollerFactory; // } // // public Collection<String> getTenacityPropertyKeys(Instance instance) { // try { // return tenacityPropertyKeyCache.get(instance, () -> // tenacityPollerFactory.create(instance).execute().orElse(null)); // } catch (CacheLoader.InvalidCacheLoadException err) { // //null was returned // } catch (Exception err) { // LOGGER.warn("Unexpected exception", err); // } // return ImmutableList.of(); // } // // public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) { // return instances // .stream() // .map(this::getTenacityPropertyKeys) // .flatMap(Collection::stream) // .collect(Collectors.toSet()); // } // } // // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // }
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.junit.Test; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when;
package com.yammer.breakerbox.service.store.tests; public class TenacityPropertyKeysStoreTest { @Test public void tenacityPropertyKeysForUris() { final TenacityPoller.Factory mockFactory = mock(TenacityPoller.Factory.class); final TenacityPoller mockPoller = mock(TenacityPoller.class); final TenacityPoller mockPoller2 = mock(TenacityPoller.class); final Instance firstInstance = new Instance("http://localhost:1234", "ignored", true); final Instance secondInstance = new Instance("http://another:8080", "ignored", true); when(mockFactory.create(firstInstance)).thenReturn(mockPoller); when(mockFactory.create(secondInstance)).thenReturn(mockPoller2); when(mockPoller.execute()).thenReturn(Optional.of(ImmutableList.of("things", "stuff"))); when(mockPoller2.execute()).thenReturn(Optional.of(ImmutableList.of("morethings", "stuff")));
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java // public class TenacityPropertyKeysStore { // private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class); // private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder // .newBuilder() // .expireAfterWrite(1, TimeUnit.MINUTES) // .build(); // private final TenacityPoller.Factory tenacityPollerFactory; // // public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) { // this.tenacityPollerFactory = tenacityPollerFactory; // } // // public Collection<String> getTenacityPropertyKeys(Instance instance) { // try { // return tenacityPropertyKeyCache.get(instance, () -> // tenacityPollerFactory.create(instance).execute().orElse(null)); // } catch (CacheLoader.InvalidCacheLoadException err) { // //null was returned // } catch (Exception err) { // LOGGER.warn("Unexpected exception", err); // } // return ImmutableList.of(); // } // // public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) { // return instances // .stream() // .map(this::getTenacityPropertyKeys) // .flatMap(Collection::stream) // .collect(Collectors.toSet()); // } // } // // Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java // public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> { // public static class Factory { // private final TurbineTenacityClient tenacityClient; // // public Factory(TurbineTenacityClient tenacityClient) { // this.tenacityClient = tenacityClient; // } // // public TenacityPoller create(Instance instance) { // return new TenacityPoller(tenacityClient, instance); // } // } // // private final TurbineTenacityClient tenacityClient; // private final Instance instance; // // public TenacityPoller(TurbineTenacityClient tenacityClient, // Instance instance) { // super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS); // this.tenacityClient = tenacityClient; // this.instance = instance; // } // // @Override // protected Optional<Collection<String>> run() throws Exception { // return tenacityClient.getTenacityPropertyKeys(instance); // } // // @Override // protected Optional<Collection<String>> getFallback() { // return Optional.empty(); // } // } // Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/store/tests/TenacityPropertyKeysStoreTest.java import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.netflix.turbine.discovery.Instance; import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore; import com.yammer.breakerbox.service.tenacity.TenacityPoller; import org.junit.Test; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; package com.yammer.breakerbox.service.store.tests; public class TenacityPropertyKeysStoreTest { @Test public void tenacityPropertyKeysForUris() { final TenacityPoller.Factory mockFactory = mock(TenacityPoller.Factory.class); final TenacityPoller mockPoller = mock(TenacityPoller.class); final TenacityPoller mockPoller2 = mock(TenacityPoller.class); final Instance firstInstance = new Instance("http://localhost:1234", "ignored", true); final Instance secondInstance = new Instance("http://another:8080", "ignored", true); when(mockFactory.create(firstInstance)).thenReturn(mockPoller); when(mockFactory.create(secondInstance)).thenReturn(mockPoller2); when(mockPoller.execute()).thenReturn(Optional.of(ImmutableList.of("things", "stuff"))); when(mockPoller2.execute()).thenReturn(Optional.of(ImmutableList.of("morethings", "stuff")));
final TenacityPropertyKeysStore tenacityPropertyKeysStore = new TenacityPropertyKeysStore(mockFactory);
yammer/breakerbox
breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // }
import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat;
package com.yammer.breakerbox.service.core.tests; public class InstancesTest { @BeforeClass public static void setupTest() throws Exception {
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // } // Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; package com.yammer.breakerbox.service.core.tests; public class InstancesTest { @BeforeClass public static void setupTest() throws Exception {
PluginsFactory.setInstanceDiscovery(new YamlInstanceDiscovery(
yammer/breakerbox
breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // }
import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat;
package com.yammer.breakerbox.service.core.tests; public class InstancesTest { @BeforeClass public static void setupTest() throws Exception { PluginsFactory.setInstanceDiscovery(new YamlInstanceDiscovery( Paths.get(Resources.getResource("turbineConfigurations/instances.yml").toURI()), Validators.newValidator(), Jackson.newObjectMapper())); } @Test public void clusters() {
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // } // Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; package com.yammer.breakerbox.service.core.tests; public class InstancesTest { @BeforeClass public static void setupTest() throws Exception { PluginsFactory.setInstanceDiscovery(new YamlInstanceDiscovery( Paths.get(Resources.getResource("turbineConfigurations/instances.yml").toURI()), Validators.newValidator(), Jackson.newObjectMapper())); } @Test public void clusters() {
assertThat(Instances.clusters())
yammer/breakerbox
breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // }
import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat;
public void clusters() { assertThat(Instances.clusters()) .isEqualTo(ImmutableSet.of("production", "mock")); } @Test public void instances() { Set<String> specifiedMetaClusters = Sets.newHashSet("PRODUCTION"); assertThat(Instances.noMetaClusters(specifiedMetaClusters)) .isEqualTo(ImmutableSet.of("mock")); } @Test public void propertyKeyUris() { assertThat(Instances .instances() .stream() .map((instance) -> URI.create("http://" + instance.getHostname())) .collect(Collectors.toSet())) .isEqualTo(ImmutableSet.of( URI.create("http://localhost:8080"), URI.create("http://completie-001.sjc1.yammer.com:8080"), URI.create("http://completie-002.sjc1.yammer.com:8080"), URI.create("http://completie-003.sjc1.yammer.com:8080"), URI.create("http://completie-004.sjc1.yammer.com:8080"), URI.create("http://deploy-001.sjc1.yammer.com:9090"))); } @Test public void instancesForCluster() {
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java // public class Instances { // private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class); // // public static Collection<Instance> instances() { // try { // return PluginsFactory.getInstanceDiscovery().getInstanceList(); // } catch (Exception err) { // LOGGER.warn("Could not fetch clusters dynamically", err); // } // // return ImmutableList.of(); // } // // public static Collection<String> clusters() { // return instances() // .stream() // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<String> noMetaClusters(Set<String> specifiedMetaClusters) { // return instances() // .stream() // .filter((instance) -> !specifiedMetaClusters.contains(instance.getCluster().toUpperCase())) // .map(Instance::getCluster) // .sorted() // .collect(Collectors.toCollection(TreeSet::new)); // } // // public static Collection<Instance> instances(ServiceId serviceId) { // return instances() // .stream() // .filter((instance) -> instance.getCluster().equals(serviceId.getId())) // .sorted() // .collect(Collectors.toList()); // } // // public static String toInstanceId(Instance instance) { // return instance.getAttributes().get(TurbineInstanceDiscovery.BREAKERBOX_INSTANCE_ID); // } // } // // Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java // public class ServiceId { // private final String id; // // private ServiceId(String id) { // this.id = id; // } // // public String getId() { // return id; // } // // public static ServiceId from(String id) { // return new ServiceId(id); // } // // @Override // public int hashCode() { // return Objects.hash(id); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final ServiceId other = (ServiceId) obj; // return Objects.equals(this.id, other.id); // } // // @Override // public String toString() { // return id; // } // } // // Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/YamlInstanceDiscovery.java // public class YamlInstanceDiscovery implements InstanceDiscovery { // private static final Logger LOGGER = LoggerFactory.getLogger(YamlInstanceDiscovery.class); // private final Path path; // private final ConfigurationFactory<YamlInstanceConfiguration> configurationFactory; // // public YamlInstanceDiscovery(Path path, // Validator validator, // ObjectMapper objectMapper) { // this.path = path; // this.configurationFactory = new YamlConfigurationFactory<>( // YamlInstanceConfiguration.class, // validator, // objectMapper, // "dw"); // parseYamlInstanceConfiguration(); // } // // @Override // public Collection<Instance> getInstanceList() throws Exception { // return parseYamlInstanceConfiguration() // .orElse(new YamlInstanceConfiguration()) // .getAllInstances(); // } // // private Optional<YamlInstanceConfiguration> parseYamlInstanceConfiguration() { // try { // return Optional.of(configurationFactory.build(path.toFile())); // } catch (Exception err) { // LOGGER.error("Unable to parse {}", path.toAbsolutePath(), err); // } // return Optional.empty(); // } // } // Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/core/tests/InstancesTest.java import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.io.Resources; import com.netflix.turbine.discovery.Instance; import com.netflix.turbine.plugins.PluginsFactory; import com.yammer.breakerbox.service.core.Instances; import com.yammer.breakerbox.store.ServiceId; import com.yammer.breakerbox.turbine.YamlInstanceDiscovery; import io.dropwizard.jackson.Jackson; import io.dropwizard.jersey.validation.Validators; import org.junit.BeforeClass; import org.junit.Test; import java.net.URI; import java.nio.file.Paths; import java.util.Set; import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; public void clusters() { assertThat(Instances.clusters()) .isEqualTo(ImmutableSet.of("production", "mock")); } @Test public void instances() { Set<String> specifiedMetaClusters = Sets.newHashSet("PRODUCTION"); assertThat(Instances.noMetaClusters(specifiedMetaClusters)) .isEqualTo(ImmutableSet.of("mock")); } @Test public void propertyKeyUris() { assertThat(Instances .instances() .stream() .map((instance) -> URI.create("http://" + instance.getHostname())) .collect(Collectors.toSet())) .isEqualTo(ImmutableSet.of( URI.create("http://localhost:8080"), URI.create("http://completie-001.sjc1.yammer.com:8080"), URI.create("http://completie-002.sjc1.yammer.com:8080"), URI.create("http://completie-003.sjc1.yammer.com:8080"), URI.create("http://completie-004.sjc1.yammer.com:8080"), URI.create("http://deploy-001.sjc1.yammer.com:9090"))); } @Test public void instancesForCluster() {
assertThat(Instances.instances(ServiceId.from("mock")))
olivergondza/jenkins-config-cloner
src/test/java/org/jenkinsci/tools/configcloner/MainTest.java
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher stdoutContains(final String expected) { // return new CommandResponseMatcher("Standard output should contain string " + expected) { // @Override protected boolean match(Accumulator item, Description desc) { // return item.stdout().contains(expected); // } // }; // } // // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher succeeded() { // return new CommandResponseMatcher("Command suceeded") { // @Override protected boolean match(Accumulator item, Description desc) { // return item.succeeded(); // } // }; // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java // public static class Accumulator extends CommandResponse{ // // final ByteArrayOutputStream out; // final ByteArrayOutputStream err; // // private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) { // // super(new PrintStream(out), new PrintStream(err)); // // this.out = out; // this.err = err; // } // // public String stdout() { // // return asString(out); // } // // public String stdout(final String pattern) { // // return decorate(out, pattern); // } // // public String stderr() { // // return asString(err); // } // // public String stderr(final String pattern) { // // return decorate(err, pattern); // } // // public void dump(final String operation) { // // System.out.println(operation + ": " + returnCode()); // System.err.print(stderr("err > %s")); // System.out.print(stdout("out > %s")); // } // // private String decorate(final ByteArrayOutputStream stream, String pattern) { // // if (!pattern.endsWith("\n")) { // // pattern += "\n"; // } // // final String in = asString(stream); // if (in.isEmpty()) return ""; // // final StringBuilder builder = new StringBuilder(in.length()); // for (final String line: asString(stream).split("\n")) { // // builder.append(String.format(pattern, line)); // } // // return builder.toString(); // } // // private String asString(final ByteArrayOutputStream stream) { // // try { // // return stream.toString("UTF-8"); // } catch (final UnsupportedEncodingException ex) { // // throw new AssertionError(ex); // } // } // // @Override // public Accumulator returnCode(final int ret) { // // return (Accumulator) super.returnCode(ret); // } // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java // public class Usage implements Handler { // // private final Main main; // // public Usage(final Main main) { // this.main = main; // } // // public CommandResponse run(final CommandResponse response) { // response.out().println("Usage: "); // for(Handler handler: main.commandMapping().values()) { // final PrintStream o = response.out(); // o.println(); // o.format("%-10s %s\n", handler.name(), handler.description()); // new CmdLineParser(handler).printUsage(o); // } // // return response; // } // // public String name() { // return "help"; // } // // public String description() { // return "Print usage"; // } // }
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.text.IsEmptyString.isEmptyString; import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains; import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded; import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator; import org.jenkinsci.tools.configcloner.handler.Usage; import org.junit.Test;
package org.jenkinsci.tools.configcloner; public class MainTest { final Accumulator rsp = CommandResponse.accumulate(); @Test public void getUsageWhenNoArgsProvided() {
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher stdoutContains(final String expected) { // return new CommandResponseMatcher("Standard output should contain string " + expected) { // @Override protected boolean match(Accumulator item, Description desc) { // return item.stdout().contains(expected); // } // }; // } // // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher succeeded() { // return new CommandResponseMatcher("Command suceeded") { // @Override protected boolean match(Accumulator item, Description desc) { // return item.succeeded(); // } // }; // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java // public static class Accumulator extends CommandResponse{ // // final ByteArrayOutputStream out; // final ByteArrayOutputStream err; // // private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) { // // super(new PrintStream(out), new PrintStream(err)); // // this.out = out; // this.err = err; // } // // public String stdout() { // // return asString(out); // } // // public String stdout(final String pattern) { // // return decorate(out, pattern); // } // // public String stderr() { // // return asString(err); // } // // public String stderr(final String pattern) { // // return decorate(err, pattern); // } // // public void dump(final String operation) { // // System.out.println(operation + ": " + returnCode()); // System.err.print(stderr("err > %s")); // System.out.print(stdout("out > %s")); // } // // private String decorate(final ByteArrayOutputStream stream, String pattern) { // // if (!pattern.endsWith("\n")) { // // pattern += "\n"; // } // // final String in = asString(stream); // if (in.isEmpty()) return ""; // // final StringBuilder builder = new StringBuilder(in.length()); // for (final String line: asString(stream).split("\n")) { // // builder.append(String.format(pattern, line)); // } // // return builder.toString(); // } // // private String asString(final ByteArrayOutputStream stream) { // // try { // // return stream.toString("UTF-8"); // } catch (final UnsupportedEncodingException ex) { // // throw new AssertionError(ex); // } // } // // @Override // public Accumulator returnCode(final int ret) { // // return (Accumulator) super.returnCode(ret); // } // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java // public class Usage implements Handler { // // private final Main main; // // public Usage(final Main main) { // this.main = main; // } // // public CommandResponse run(final CommandResponse response) { // response.out().println("Usage: "); // for(Handler handler: main.commandMapping().values()) { // final PrintStream o = response.out(); // o.println(); // o.format("%-10s %s\n", handler.name(), handler.description()); // new CmdLineParser(handler).printUsage(o); // } // // return response; // } // // public String name() { // return "help"; // } // // public String description() { // return "Print usage"; // } // } // Path: src/test/java/org/jenkinsci/tools/configcloner/MainTest.java import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.text.IsEmptyString.isEmptyString; import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains; import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded; import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator; import org.jenkinsci.tools.configcloner.handler.Usage; import org.junit.Test; package org.jenkinsci.tools.configcloner; public class MainTest { final Accumulator rsp = CommandResponse.accumulate(); @Test public void getUsageWhenNoArgsProvided() {
assertThat(run().getHandler(), instanceOf(Usage.class));
olivergondza/jenkins-config-cloner
src/test/java/org/jenkinsci/tools/configcloner/MainTest.java
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher stdoutContains(final String expected) { // return new CommandResponseMatcher("Standard output should contain string " + expected) { // @Override protected boolean match(Accumulator item, Description desc) { // return item.stdout().contains(expected); // } // }; // } // // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher succeeded() { // return new CommandResponseMatcher("Command suceeded") { // @Override protected boolean match(Accumulator item, Description desc) { // return item.succeeded(); // } // }; // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java // public static class Accumulator extends CommandResponse{ // // final ByteArrayOutputStream out; // final ByteArrayOutputStream err; // // private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) { // // super(new PrintStream(out), new PrintStream(err)); // // this.out = out; // this.err = err; // } // // public String stdout() { // // return asString(out); // } // // public String stdout(final String pattern) { // // return decorate(out, pattern); // } // // public String stderr() { // // return asString(err); // } // // public String stderr(final String pattern) { // // return decorate(err, pattern); // } // // public void dump(final String operation) { // // System.out.println(operation + ": " + returnCode()); // System.err.print(stderr("err > %s")); // System.out.print(stdout("out > %s")); // } // // private String decorate(final ByteArrayOutputStream stream, String pattern) { // // if (!pattern.endsWith("\n")) { // // pattern += "\n"; // } // // final String in = asString(stream); // if (in.isEmpty()) return ""; // // final StringBuilder builder = new StringBuilder(in.length()); // for (final String line: asString(stream).split("\n")) { // // builder.append(String.format(pattern, line)); // } // // return builder.toString(); // } // // private String asString(final ByteArrayOutputStream stream) { // // try { // // return stream.toString("UTF-8"); // } catch (final UnsupportedEncodingException ex) { // // throw new AssertionError(ex); // } // } // // @Override // public Accumulator returnCode(final int ret) { // // return (Accumulator) super.returnCode(ret); // } // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java // public class Usage implements Handler { // // private final Main main; // // public Usage(final Main main) { // this.main = main; // } // // public CommandResponse run(final CommandResponse response) { // response.out().println("Usage: "); // for(Handler handler: main.commandMapping().values()) { // final PrintStream o = response.out(); // o.println(); // o.format("%-10s %s\n", handler.name(), handler.description()); // new CmdLineParser(handler).printUsage(o); // } // // return response; // } // // public String name() { // return "help"; // } // // public String description() { // return "Print usage"; // } // }
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.text.IsEmptyString.isEmptyString; import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains; import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded; import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator; import org.jenkinsci.tools.configcloner.handler.Usage; import org.junit.Test;
package org.jenkinsci.tools.configcloner; public class MainTest { final Accumulator rsp = CommandResponse.accumulate(); @Test public void getUsageWhenNoArgsProvided() { assertThat(run().getHandler(), instanceOf(Usage.class)); } @Test public void getUsageWhenInvalidArgsProvided() { assertThat(run("no-such-command").getHandler(), instanceOf(Usage.class)); } @Test public void failedValidationShouldInvokeUsage() { run("job", "invalid-arg");
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher stdoutContains(final String expected) { // return new CommandResponseMatcher("Standard output should contain string " + expected) { // @Override protected boolean match(Accumulator item, Description desc) { // return item.stdout().contains(expected); // } // }; // } // // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java // public static CommandResponseMatcher succeeded() { // return new CommandResponseMatcher("Command suceeded") { // @Override protected boolean match(Accumulator item, Description desc) { // return item.succeeded(); // } // }; // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java // public static class Accumulator extends CommandResponse{ // // final ByteArrayOutputStream out; // final ByteArrayOutputStream err; // // private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) { // // super(new PrintStream(out), new PrintStream(err)); // // this.out = out; // this.err = err; // } // // public String stdout() { // // return asString(out); // } // // public String stdout(final String pattern) { // // return decorate(out, pattern); // } // // public String stderr() { // // return asString(err); // } // // public String stderr(final String pattern) { // // return decorate(err, pattern); // } // // public void dump(final String operation) { // // System.out.println(operation + ": " + returnCode()); // System.err.print(stderr("err > %s")); // System.out.print(stdout("out > %s")); // } // // private String decorate(final ByteArrayOutputStream stream, String pattern) { // // if (!pattern.endsWith("\n")) { // // pattern += "\n"; // } // // final String in = asString(stream); // if (in.isEmpty()) return ""; // // final StringBuilder builder = new StringBuilder(in.length()); // for (final String line: asString(stream).split("\n")) { // // builder.append(String.format(pattern, line)); // } // // return builder.toString(); // } // // private String asString(final ByteArrayOutputStream stream) { // // try { // // return stream.toString("UTF-8"); // } catch (final UnsupportedEncodingException ex) { // // throw new AssertionError(ex); // } // } // // @Override // public Accumulator returnCode(final int ret) { // // return (Accumulator) super.returnCode(ret); // } // } // // Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java // public class Usage implements Handler { // // private final Main main; // // public Usage(final Main main) { // this.main = main; // } // // public CommandResponse run(final CommandResponse response) { // response.out().println("Usage: "); // for(Handler handler: main.commandMapping().values()) { // final PrintStream o = response.out(); // o.println(); // o.format("%-10s %s\n", handler.name(), handler.description()); // new CmdLineParser(handler).printUsage(o); // } // // return response; // } // // public String name() { // return "help"; // } // // public String description() { // return "Print usage"; // } // } // Path: src/test/java/org/jenkinsci/tools/configcloner/MainTest.java import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.text.IsEmptyString.isEmptyString; import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains; import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded; import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator; import org.jenkinsci.tools.configcloner.handler.Usage; import org.junit.Test; package org.jenkinsci.tools.configcloner; public class MainTest { final Accumulator rsp = CommandResponse.accumulate(); @Test public void getUsageWhenNoArgsProvided() { assertThat(run().getHandler(), instanceOf(Usage.class)); } @Test public void getUsageWhenInvalidArgsProvided() { assertThat(run("no-such-command").getHandler(), instanceOf(Usage.class)); } @Test public void failedValidationShouldInvokeUsage() { run("job", "invalid-arg");
assertThat(rsp, not(succeeded()));