EditLogBackupOutputStream(NamenodeRegistration bnReg, // backup node JournalInfo journalInfo) // active name-node throws IOException { super(); this.bnRegistration = bnReg; this.journalInfo = journalInfo; InetSocketAddress bnAddress = NetUtils.createSocketAddr(bnRegistration.getAddress()); try { this.backupNode = NameNodeProxies.createNonHAProxy(new HdfsConfiguration(), bnAddress, JournalProtocol.class, UserGroupInformation.getCurrentUser(), true).getProxy(); } catch(IOException e) { Storage.LOG.error("Error connecting to: " + bnAddress, e); throw e; } this.doubleBuf = new EditsDoubleBuffer(DEFAULT_BUFFER_SIZE); this.out = new DataOutputBuffer(DEFAULT_BUFFER_SIZE); }
/** * Creates an explicitly non-HA-enabled proxy object. Most of the time you * don't want to use this, and should instead use {@link NameNodeProxies#createProxy}. * * @param conf the configuration object * @param nnAddr address of the remote NN to connect to * @param xface the IPC interface which should be created * @param ugi the user who is making the calls on the proxy object * @param withRetries certain interfaces have a non-standard retry policy * @param fallbackToSimpleAuth - set to true or false during this method to * indicate if a secure client falls back to simple auth * @return an object containing both the proxy and the associated * delegation token service it corresponds to * @throws IOException */ @SuppressWarnings("unchecked") public static <T> ProxyAndInfo<T> createNonHAProxy( Configuration conf, InetSocketAddress nnAddr, Class<T> xface, UserGroupInformation ugi, boolean withRetries, AtomicBoolean fallbackToSimpleAuth) throws IOException { Text dtService = SecurityUtil.buildTokenService(nnAddr); T proxy; if (xface == ClientProtocol.class) { proxy = (T) createNNProxyWithClientProtocol(nnAddr, conf, ugi, withRetries, fallbackToSimpleAuth); } else if (xface == JournalProtocol.class) { proxy = (T) createNNProxyWithJournalProtocol(nnAddr, conf, ugi); } else if (xface == NamenodeProtocol.class) { proxy = (T) createNNProxyWithNamenodeProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == GetUserMappingsProtocol.class) { proxy = (T) createNNProxyWithGetUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshUserMappingsProtocol.class) { proxy = (T) createNNProxyWithRefreshUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshAuthorizationPolicyProtocol.class) { proxy = (T) createNNProxyWithRefreshAuthorizationPolicyProtocol(nnAddr, conf, ugi); } else if (xface == RefreshCallQueueProtocol.class) { proxy = (T) createNNProxyWithRefreshCallQueueProtocol(nnAddr, conf, ugi); } else { String message = "Unsupported protocol found when creating the proxy " + "connection to NameNode: " + ((xface != null) ? xface.getClass().getName() : "null"); LOG.error(message); throw new IllegalStateException(message); } return new ProxyAndInfo<T>(proxy, dtService, nnAddr); }
private static JournalProtocol createNNProxyWithJournalProtocol( InetSocketAddress address, Configuration conf, UserGroupInformation ugi) throws IOException { JournalProtocolPB proxy = (JournalProtocolPB) createNameNodeProxy(address, conf, ugi, JournalProtocolPB.class); return new JournalProtocolTranslatorPB(proxy); }
@Test public void tesJournalProtocol() throws IOException { JournalProtocolTranslatorPB translator = (JournalProtocolTranslatorPB) NameNodeProxies.createNonHAProxy(conf, nnAddress, JournalProtocol.class, UserGroupInformation.getCurrentUser(), true).getProxy(); //Nameode doesn't implement JournalProtocol assertFalse(translator.isMethodSupported("startLogSegment")); }
/** * Creates an explicitly non-HA-enabled proxy object. Most of the time you * don't want to use this, and should instead use {@link NameNodeProxies#createProxy}. * * @param conf the configuration object * @param nnAddr address of the remote NN to connect to * @param xface the IPC interface which should be created * @param ugi the user who is making the calls on the proxy object * @param withRetries certain interfaces have a non-standard retry policy * @param fallbackToSimpleAuth - set to true or false during this method to * indicate if a secure client falls back to simple auth * @return an object containing both the proxy and the associated * delegation token service it corresponds to * @throws IOException */ @SuppressWarnings("unchecked") public static <T> ProxyAndInfo<T> createNonHAProxy( Configuration conf, InetSocketAddress nnAddr, Class<T> xface, UserGroupInformation ugi, boolean withRetries, AtomicBoolean fallbackToSimpleAuth) throws IOException { Text dtService = SecurityUtil.buildTokenService(nnAddr); T proxy; if (xface == ClientProtocol.class) { proxy = (T) NameNodeProxiesClient.createNonHAProxyWithClientProtocol( nnAddr, conf, ugi, withRetries, fallbackToSimpleAuth); } else if (xface == JournalProtocol.class) { proxy = (T) createNNProxyWithJournalProtocol(nnAddr, conf, ugi); } else if (xface == NamenodeProtocol.class) { proxy = (T) createNNProxyWithNamenodeProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == GetUserMappingsProtocol.class) { proxy = (T) createNNProxyWithGetUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshUserMappingsProtocol.class) { proxy = (T) createNNProxyWithRefreshUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshAuthorizationPolicyProtocol.class) { proxy = (T) createNNProxyWithRefreshAuthorizationPolicyProtocol(nnAddr, conf, ugi); } else if (xface == RefreshCallQueueProtocol.class) { proxy = (T) createNNProxyWithRefreshCallQueueProtocol(nnAddr, conf, ugi); } else { String message = "Unsupported protocol found when creating the proxy " + "connection to NameNode: " + ((xface != null) ? xface.getClass().getName() : "null"); LOG.error(message); throw new IllegalStateException(message); } return new ProxyAndInfo<T>(proxy, dtService, nnAddr); }
private static JournalProtocol createNNProxyWithJournalProtocol( InetSocketAddress address, Configuration conf, UserGroupInformation ugi) throws IOException { JournalProtocolPB proxy = (JournalProtocolPB) createNameNodeProxy(address, conf, ugi, JournalProtocolPB.class, 30000); return new JournalProtocolTranslatorPB(proxy); }
/** * Creates an explicitly non-HA-enabled proxy object. Most of the time you * don't want to use this, and should instead use {@link NameNodeProxies#createProxy}. * * @param conf the configuration object * @param nnAddr address of the remote NN to connect to * @param xface the IPC interface which should be created * @param ugi the user who is making the calls on the proxy object * @param withRetries certain interfaces have a non-standard retry policy * @return an object containing both the proxy and the associated * delegation token service it corresponds to * @throws IOException */ @SuppressWarnings("unchecked") public static <T> ProxyAndInfo<T> createNonHAProxy( Configuration conf, InetSocketAddress nnAddr, Class<T> xface, UserGroupInformation ugi, boolean withRetries) throws IOException { Text dtService = SecurityUtil.buildTokenService(nnAddr); T proxy; if (xface == ClientProtocol.class) { proxy = (T) createNNProxyWithClientProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == JournalProtocol.class) { proxy = (T) createNNProxyWithJournalProtocol(nnAddr, conf, ugi); } else if (xface == NamenodeProtocol.class) { proxy = (T) createNNProxyWithNamenodeProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == GetUserMappingsProtocol.class) { proxy = (T) createNNProxyWithGetUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshUserMappingsProtocol.class) { proxy = (T) createNNProxyWithRefreshUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshAuthorizationPolicyProtocol.class) { proxy = (T) createNNProxyWithRefreshAuthorizationPolicyProtocol(nnAddr, conf, ugi); } else { String message = "Upsupported protocol found when creating the proxy " + "connection to NameNode: " + ((xface != null) ? xface.getClass().getName() : "null"); LOG.error(message); throw new IllegalStateException(message); } return new ProxyAndInfo<T>(proxy, dtService); }
/** * Creates an explicitly non-HA-enabled proxy object. Most of the time you * don't want to use this, and should instead use {@link NameNodeProxies#createProxy}. * * @param conf the configuration object * @param nnAddr address of the remote NN to connect to * @param xface the IPC interface which should be created * @param ugi the user who is making the calls on the proxy object * @param withRetries certain interfaces have a non-standard retry policy * @return an object containing both the proxy and the associated * delegation token service it corresponds to * @throws IOException */ @SuppressWarnings("unchecked") public static <T> ProxyAndInfo<T> createNonHAProxy( Configuration conf, InetSocketAddress nnAddr, Class<T> xface, UserGroupInformation ugi, boolean withRetries) throws IOException { Text dtService = SecurityUtil.buildTokenService(nnAddr); T proxy; if (xface == ClientProtocol.class) { proxy = (T) createNNProxyWithClientProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == JournalProtocol.class) { proxy = (T) createNNProxyWithJournalProtocol(nnAddr, conf, ugi); } else if (xface == NamenodeProtocol.class) { proxy = (T) createNNProxyWithNamenodeProtocol(nnAddr, conf, ugi, withRetries); } else if (xface == GetUserMappingsProtocol.class) { proxy = (T) createNNProxyWithGetUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshUserMappingsProtocol.class) { proxy = (T) createNNProxyWithRefreshUserMappingsProtocol(nnAddr, conf, ugi); } else if (xface == RefreshAuthorizationPolicyProtocol.class) { proxy = (T) createNNProxyWithRefreshAuthorizationPolicyProtocol(nnAddr, conf, ugi); } else if (xface == RefreshCallQueueProtocol.class) { proxy = (T) createNNProxyWithRefreshCallQueueProtocol(nnAddr, conf, ugi); } else { String message = "Unsupported protocol found when creating the proxy " + "connection to NameNode: " + ((xface != null) ? xface.getClass().getName() : "null"); LOG.error(message); throw new IllegalStateException(message); } return new ProxyAndInfo<T>(proxy, dtService); }
public JournalProtocolServerSideTranslatorPB(JournalProtocol impl) { this.impl = impl; }