static Class<? extends VersionedProtocol> getProtocolClass(String protocolName) throws ClassNotFoundException { Class<? extends VersionedProtocol> protocol = PROTOCOL_CACHE.get(protocolName); if (protocol == null) { protocol = (Class<? extends VersionedProtocol>) ClassUtils.getProtocolByName(protocolName); PROTOCOL_CACHE.put(protocolName, protocol); } return protocol; }
@Override public void read(final DataInput in) throws IOException { // Read job id this.jobID.read(in); // Read the job name this.jobName = StringRecord.readString(in); // Read required jar files readRequiredJarFiles(in); // First read total number of vertices; final int numVertices = in.readInt(); // First, recreate each vertex and add it to reconstructionMap for (int i = 0; i < numVertices; i++) { final String className = StringRecord.readString(in); final JobVertexID id = new JobVertexID(); id.read(in); final String vertexName = StringRecord.readString(in); Class<? extends IOReadableWritable> c; try { c = ClassUtils.getRecordByName(className); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe.toString()); } // Find constructor Constructor<? extends IOReadableWritable> cst; try { cst = c.getConstructor(String.class, JobVertexID.class, JobGraph.class); } catch (SecurityException e1) { throw new IOException(e1.toString()); } catch (NoSuchMethodException e1) { throw new IOException(e1.toString()); } try { cst.newInstance(vertexName, id, this); } catch (IllegalArgumentException e) { throw new IOException(e.toString()); } catch (InstantiationException e) { throw new IOException(e.toString()); } catch (IllegalAccessException e) { throw new IOException(e.toString()); } catch (InvocationTargetException e) { throw new IOException(e.toString()); } } final JobVertexID tmpID = new JobVertexID(); for (int i = 0; i < numVertices; i++) { AbstractJobVertex jv; tmpID.read(in); if (inputVertices.containsKey(tmpID)) { jv = inputVertices.get(tmpID); } else { if (outputVertices.containsKey(tmpID)) { jv = outputVertices.get(tmpID); } else { if (taskVertices.containsKey(tmpID)) { jv = taskVertices.get(tmpID); } else { throw new IOException("Cannot find vertex with ID " + tmpID + " in any vertex map."); } } } // Read the vertex data jv.read(in); } // Find the class loader for the job final ClassLoader cl = LibraryCacheManager.getClassLoader(this.jobID); if (cl == null) { throw new IOException("Cannot find class loader for job graph " + this.jobID); } // Re-instantiate the job configuration object and read the configuration this.jobConfiguration = new Configuration(cl); this.jobConfiguration.read(in); }