// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/PersonalizedCatalogCommand.java
// public static class Video implements ID {
// 
//     private final int id;
// 
//     public Video(int id) {
//         this.id = id;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/VideoMetadataCommand.java
// public static class VideoMetadata {
// 
//     private final Map<String, Object> data;
// 
//     public VideoMetadata(Map<String, Object> data) {
//         this.data = data;
//     }
// 
//     public static VideoMetadata fromJson(String json) {
//         return new VideoMetadata(SimpleJson.jsonToMap(json));
//     }
// 
//     public int getId() {
//         return (int) data.get("videoId");
//     }
// 
//     public String getTitle() {
//         return (String) data.get("title");
//     }
// 
//     public Map<String, Object> getDataAsMap() {
//         return data;
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/common/SimpleJson.java
// public class SimpleJson {
// 
//     private static final SimpleJson INSTANCE = new SimpleJson();
// 
//     private SimpleJson() {
// 
//     }
// 
//     public static Map<String, Object> jsonToMap(String jsonString) {
//         return INSTANCE._jsonToMap(jsonString);
//     }
// 
//     public static String mapToJson(Map<String, ? extends Object> map) {
//         return INSTANCE._mapToJson(map);
//     }
// 
//     private final ObjectMapper objectMapper = new ObjectMapper();
//     private final ObjectReader objectReader = objectMapper.reader(Map.class);
// 
//     private Map<String, Object> _jsonToMap(String jsonString) {
//         try {
//             return objectReader.readValue(jsonString);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to parse JSON", e);
//         }
//     }
// 
//     private final ObjectWriter objectWriter = objectMapper.writerWithType(Map.class);
// 
//     private String _mapToJson(Map<String, ? extends Object> map) {
//         try {
//             return objectWriter.writeValueAsString(map);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to write JSON", e);
//         }
//     }
// }


import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixObservableCommand;
import io.netty.buffer.ByteBuf;
import io.reactivex.lab.gateway.clients.PersonalizedCatalogCommand.Video;
import io.reactivex.lab.gateway.clients.VideoMetadataCommand.VideoMetadata;
import io.reactivex.lab.gateway.common.SimpleJson;
import io.reactivex.lab.gateway.loadbalancer.DiscoveryAndLoadBalancer;
import io.reactivex.netty.protocol.http.client.HttpClientRequest;
import io.reactivex.netty.protocol.http.sse.ServerSentEvent;
import netflix.ocelli.LoadBalancer;
import netflix.ocelli.rxnetty.HttpClientHolder;
import rx.Observable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package io.reactivex.lab.gateway.clients;




public class VideoMetadataCommand extends HystrixObservableCommand<VideoMetadata> {

    private final List<Video> videos;
    private static final LoadBalancer<HttpClientHolder<ByteBuf, ServerSentEvent>> loadBalancer =
            DiscoveryAndLoadBalancer.getFactory().forVip("reactive-lab-vms-service");

// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/PersonalizedCatalogCommand.java
// public static class Video implements ID {
// 
//     private final int id;
// 
//     public Video(int id) {
//         this.id = id;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/VideoMetadataCommand.java
// public static class VideoMetadata {
// 
//     private final Map<String, Object> data;
// 
//     public VideoMetadata(Map<String, Object> data) {
//         this.data = data;
//     }
// 
//     public static VideoMetadata fromJson(String json) {
//         return new VideoMetadata(SimpleJson.jsonToMap(json));
//     }
// 
//     public int getId() {
//         return (int) data.get("videoId");
//     }
// 
//     public String getTitle() {
//         return (String) data.get("title");
//     }
// 
//     public Map<String, Object> getDataAsMap() {
//         return data;
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/common/SimpleJson.java
// public class SimpleJson {
// 
//     private static final SimpleJson INSTANCE = new SimpleJson();
// 
//     private SimpleJson() {
// 
//     }
// 
//     public static Map<String, Object> jsonToMap(String jsonString) {
//         return INSTANCE._jsonToMap(jsonString);
//     }
// 
//     public static String mapToJson(Map<String, ? extends Object> map) {
//         return INSTANCE._mapToJson(map);
//     }
// 
//     private final ObjectMapper objectMapper = new ObjectMapper();
//     private final ObjectReader objectReader = objectMapper.reader(Map.class);
// 
//     private Map<String, Object> _jsonToMap(String jsonString) {
//         try {
//             return objectReader.readValue(jsonString);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to parse JSON", e);
//         }
//     }
// 
//     private final ObjectWriter objectWriter = objectMapper.writerWithType(Map.class);
// 
//     private String _mapToJson(Map<String, ? extends Object> map) {
//         try {
//             return objectWriter.writeValueAsString(map);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to write JSON", e);
//         }
//     }
// }


// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/VideoMetadataCommand.java
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixObservableCommand;
import io.netty.buffer.ByteBuf;
import io.reactivex.lab.gateway.clients.PersonalizedCatalogCommand.Video;
import io.reactivex.lab.gateway.clients.VideoMetadataCommand.VideoMetadata;
import io.reactivex.lab.gateway.common.SimpleJson;
import io.reactivex.lab.gateway.loadbalancer.DiscoveryAndLoadBalancer;
import io.reactivex.netty.protocol.http.client.HttpClientRequest;
import io.reactivex.netty.protocol.http.sse.ServerSentEvent;
import netflix.ocelli.LoadBalancer;
import netflix.ocelli.rxnetty.HttpClientHolder;
import rx.Observable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

package io.reactivex.lab.gateway.clients;




public class VideoMetadataCommand extends HystrixObservableCommand<VideoMetadata> {

    private final List<Video> videos;
    private static final LoadBalancer<HttpClientHolder<ByteBuf, ServerSentEvent>> loadBalancer =
            DiscoveryAndLoadBalancer.getFactory().forVip("reactive-lab-vms-service");

    public VideoMetadataCommand(Video video) {