@@ -0,0 +1,2456 @@
+/*%0A * Copyright (c) 2013 by Johannes Dillmann, Zuse Institute Berlin%0A *%0A * Licensed under the BSD License, see LICENSE file for details.%0A *%0A */%0A%0Apackage org.xtreemfs.osd;%0A%0Aimport java.io.IOException;%0Aimport java.util.Map;%0Aimport java.util.concurrent.atomic.AtomicReference;%0A%0Aimport org.xtreemfs.common.statusserver.StatusServerModule;%0Aimport org.xtreemfs.foundation.json.JSONParser;%0Aimport org.xtreemfs.osd.rwre.RWReplicationStage;%0Aimport org.xtreemfs.pbrpc.generatedinterfaces.DIR.ServiceType;%0A%0Aimport com.sun.net.httpserver.HttpExchange;%0A%0Apublic class ReplicatedFileStatusJSON extends StatusServerModule %7B%0A%0A    private OSDRequestDispatcher myDispatcher;%0A%0A    @Override%0A    public String getDisplayName() %7B%0A        return %22OSD Replicated File Table JSON Interface%22;%0A    %7D%0A%0A    @Override%0A    public String getUriPath() %7B%0A        return %22/rft.json%22;%0A    %7D%0A%0A    @Override%0A    public boolean isAvailableForService(ServiceType service) %7B%0A        return service == ServiceType.SERVICE_TYPE_OSD;%0A    %7D%0A%0A    @Override%0A    public void initialize(ServiceType service, Object serviceRequestDispatcher) %7B%0A        assert (service == ServiceType.SERVICE_TYPE_OSD);%0A        myDispatcher = (OSDRequestDispatcher) serviceRequestDispatcher;%0A    %7D%0A%0A    @Override%0A    public void shutdown() %7B%0A    %7D%0A%0A    @Override%0A    public void handle(HttpExchange httpExchange) throws IOException %7B%0A        try %7B%0A            final AtomicReference%3CMap%3CString, Map%3CString, String%3E%3E%3E result = new AtomicReference%3CMap%3CString, Map%3CString, String%3E%3E%3E();%0A%0A            myDispatcher.getRWReplicationStage().getStatus(new RWReplicationStage.StatusCallback() %7B%0A%0A                @Override%0A                public void statusComplete(Map%3CString, Map%3CString, String%3E%3E status) %7B%0A                    synchronized (result) %7B%0A                        result.set(status);%0A                        result.notifyAll();%0A                    %7D%0A                %7D%0A            %7D);%0A            synchronized (result) %7B%0A                if (result.get() == null)%0A                    result.wait();%0A            %7D%0A            Map%3CString, Map%3CString, String%3E%3E status = result.get();%0A%0A            String statusJSON = JSONParser.writeJSON(status);%0A%0A            httpExchange.getResponseHeaders().set(%22Content-Type%22, %22application/json%22);%0A            sendResponse(httpExchange, statusJSON);%0A%0A        %7D catch (Throwable ex) %7B%0A            ex.printStackTrace();%0A            httpExchange.sendResponseHeaders(500, 0);%0A        %7D%0A    %7D%0A%0A%7D%0A

Make ReplicatedFileStatus available as JSON