@Override public HashMap<String, Object> toJson(HashMap<String, Object> output) { Connection conn = null; PreparedStatement ps = null; PreparedStatement actions = null; PreparedStatement queues = null; ResultSet set = null; ResultSet actionSet = null; ResultSet queueSet = null; HashMap<String, Object> fs = new HashMap<String, Object>(); HashMap<String, Object> action = new HashMap<String, Object>(); LinkedList<Object> list = new LinkedList<Object>(); LinkedList<Object> actionList = new LinkedList<Object>(); LinkedList<Integer> queueList = new LinkedList<Integer>(); try { int wildcards = -1; conn = settings.getConnection(); ps = conn.prepareStatement(GFLOWMAP); set = ps.executeQuery(); // writer.name(FS); // writer.beginArray(); while (set.next()) { // writer.beginObject(); wildcards = set.getInt(WILDCARDS); fs.put(DPID, FlowSpaceUtil.dpidToString(set.getLong(DPID))); fs.put(PRIO, set.getInt(PRIO)); if ((wildcards & FVMatch.OFPFW_IN_PORT) == 0) fs.put(INPORT, set.getInt(INPORT)); if ((wildcards & FVMatch.OFPFW_DL_VLAN) == 0) fs.put(VLAN, set.getShort(VLAN)); if ((wildcards & FVMatch.OFPFW_DL_VLAN_PCP) == 0) fs.put(VPCP, set.getShort(VPCP)); if ((wildcards & FVMatch.OFPFW_DL_SRC) == 0) fs.put(DLSRC, FlowSpaceUtil.macToString(set.getLong(DLSRC))); if ((wildcards & FVMatch.OFPFW_DL_DST) == 0) fs.put(DLDST, FlowSpaceUtil.macToString(set.getLong(DLDST))); if ((wildcards & FVMatch.OFPFW_DL_TYPE) == 0) fs.put(DLTYPE, set.getShort(DLTYPE)); if ((wildcards & FVMatch.OFPFW_NW_SRC_ALL) == 0) fs.put(NWSRC, set.getInt(NWSRC)); if ((wildcards & FVMatch.OFPFW_NW_DST_ALL) == 0) fs.put(NWDST, set.getInt(NWDST)); if ((wildcards & FVMatch.OFPFW_NW_PROTO) == 0) fs.put(NWPROTO, set.getShort(NWPROTO)); if ((wildcards & FVMatch.OFPFW_NW_TOS) == 0) fs.put(NWTOS, set.getShort(NWTOS)); if ((wildcards & FVMatch.OFPFW_TP_DST) == 0) fs.put(TPDST, set.getShort(TPDST)); if ((wildcards & FVMatch.OFPFW_TP_SRC) == 0) fs.put(TPSRC, set.getShort(TPSRC)); fs.put(FORCED_QUEUE, set.getInt(FORCED_QUEUE)); fs.put(WILDCARDS, wildcards); // fs.put(QUEUE, set.getInt(QUEUE)); actions = conn.prepareStatement(GACTIONS); actions.setInt(1, set.getInt("id")); actionSet = actions.executeQuery(); // writer.name(ACTION); // writer.beginArray(); while (actionSet.next()) { action.put(actionSet.getString(Slice.SLICE), actionSet.getInt(ACTION)); actionList.add(action.clone()); action.clear(); } fs.put(ACTION, actionList.clone()); actionList.clear(); queues = conn.prepareStatement(GQUEUES); queues.setInt(1, set.getInt("id")); queueSet = queues.executeQuery(); while (queueSet.next()) { queueList.add(queueSet.getInt(QUEUE)); } fs.put(QUEUE, queueList.clone()); queueList.clear(); list.add(fs.clone()); fs.clear(); } output.put(FS, list); } catch (SQLException e) { FVLog.log(LogLevel.CRIT, null, "Failed to write flowspace config : " + e.getMessage()); } finally { close(set); close(ps); close(actionSet); close(actions); close(queueSet); close(queues); close(conn); } return output; }