public Either<String, List<Interval>> segments(String dataSource, Map<String, String> reqHeaders) {
        Either<String, Either<JSONArray, JSONObject>> resp = fireCommand("druid/coordinator/v1/metadata/datasources/" + dataSource + "/segments?full", null, reqHeaders);
        if (resp.isLeft()) {
            return new Left<>(resp.left().get());
        }
        Either<JSONArray, JSONObject> mayBgoodResp = resp.right().get();
        if (mayBgoodResp.isLeft()) {
            JSONArray segments = mayBgoodResp.left().get();
            List<Interval> segmentsList = new ArrayList<>();
            for (int i = 0; i < segments.length(); i++) {
                JSONObject segment = segments.getJSONObject(i);
                segmentsList.add(new Interval(segment.getString("interval")));
            }
            return new Right<>(segmentsList);
        }
        return new Left<>(mayBgoodResp.right().get().toString());
    }
public Either < String , List < Interval > > segments ( String dataSource , Map < String , String > reqHeaders ) { Either < String , Either < JSONArray , JSONObject > > resp = fireCommand ( "druid/coordinator/v1/metadata/datasources/" + dataSource + "/segments?full" , null , reqHeaders ) ; if ( resp . isLeft ( ) ) { return new Left < > ( resp . left ( ) . get ( ) ) ; } Either < JSONArray , JSONObject > mayBgoodResp = resp . right ( ) . get ( ) ; if ( mayBgoodResp . isLeft ( ) ) { JSONArray segments = mayBgoodResp . left ( ) . get ( ) ; List < Interval > segmentsList = new ArrayList < > ( ) ; for ( int i = 0 ; i < segments . length ( ) ; i ++ ) { JSONObject segment = segments . getJSONObject ( i ) ; segmentsList . add ( new Interval ( segment . getString ( "interval" ) ) ) ; } return new Right < > ( segmentsList ) ; } return new Left < > ( mayBgoodResp . right ( ) . get ( ) . toString ( ) ) ; }
Ex:response looks something like this.
[{"dataSource":"abf2","interval":"2014-10-31T00:00:00.000-07:00/2014-11-01T00:00:00.000-07:00","version":"2014-11-13T21:53:23.982-08:00","loadSpec":{..},..},
{"dataSource":"abf2","interval":"2014-11-01T00:00:00.000-07:00/2014-11-02T00:00:00.000-07:00","version":"2014-11-13T22:01:23.554-08:00","loadSpec":{..},..}
.... ]

@param dataSource
@param reqHeaders
@return List[intervals] Ex:
["2014-10-31T00:00:00.000-07:00/2014-11-01T00:00:00.000-07:00",
"2014-11-01T00:00:00.000-07:00/2014-11-02T00:00:00.000-07:00" .. ]