use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.
the class HadoopConfsUtils method getConfsJarDefaultNames.
/**
* Get all conf jars names. If the connection is in context mode each context group will has one conf jar, otherwise
* there will be only one conf jar.
*
* @param connectionItem
* @param createJarIfNotExist
*
* @return
*/
public static Set<String> getConfsJarDefaultNames(HadoopClusterConnectionItem connectionItem, boolean createJarIfNotExist) {
Set<String> jarNames = new HashSet<>();
HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
if (connection.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
if (contextItem != null) {
EList<ContextType> contexts = contextItem.getContext();
for (ContextType contextType : contexts) {
jarNames.add(HadoopConfsUtils.getConfsJarDefaultName(connectionItem, createJarIfNotExist, contextType.getName()));
}
}
} else {
jarNames.add(HadoopConfsUtils.getConfsJarDefaultName(connectionItem, createJarIfNotExist));
}
return jarNames;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.
the class HadoopConfsUtils method createAndDeployConfJar.
private static void createAndDeployConfJar(HadoopClusterConnectionItem connectionItem, String confJarId, String confJarName) throws IOException {
// If the conf jar has been deployed before then no need to deploy again.
if (containsInDeployedCache(connectionItem, confJarName)) {
return;
}
byte[] confFileBA = null;
HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
if (connection.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
if (contextItem != null) {
EMap<String, byte[]> confFiles = connection.getConfFiles();
EList<ContextType> contexts = contextItem.getContext();
for (ContextType contextType : contexts) {
String contextName = contextType.getName();
byte[] bs = confFiles.get(contextName);
if (confJarId.endsWith(contextName) && bs != null) {
confFileBA = bs;
break;
}
}
}
if (confFileBA == null) {
// either conf jar name is wrong or it is a old item.
// then take the old hadoop conf file content.
confFileBA = connection.getConfFile();
}
} else {
confFileBA = connection.getConfFile();
}
if (confFileBA != null) {
File confsTempFolder = new File(getConfsJarTempFolder());
File confFile = new File(confsTempFolder, confJarName);
FileUtils.writeByteArrayToFile(confFile, confFileBA);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService libService = GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
if (libService != null && libService.isJarNeedToBeDeployed(confFile)) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService service = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
if (service != null) {
// Only deploy a new jar, no need to reset all
service.deployLibrary(confFile.toURI().toURL());
addToDeployedCache(connectionItem, confJarName);
}
}
}
}
}
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.
the class GoogleDataprocInfoForm method initCommonProperties.
private void initCommonProperties(HadoopServiceProperties properties) {
HadoopClusterConnection connection = getConnection();
ContextType contextType = null;
if (getConnection().isContextMode()) {
contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, connection.getContextName(), false);
}
properties.setContextType(contextType);
properties.setRelativeHadoopClusterId(connectionItem.getProperty().getId());
properties.setRelativeHadoopClusterLabel(connectionItem.getProperty().getLabel());
properties.setDistribution(connection.getDistribution());
properties.setVersion(connection.getDfVersion());
properties.setUseKrb(connection.isEnableKerberos());
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.
the class KnoxInfoForm method initCommonProperties.
private void initCommonProperties(HadoopServiceProperties properties) {
HadoopClusterConnection connection = getConnection();
ContextType contextType = null;
if (getConnection().isContextMode()) {
contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, connection.getContextName(), false);
}
properties.setContextType(contextType);
properties.setRelativeHadoopClusterId(connectionItem.getProperty().getId());
properties.setRelativeHadoopClusterLabel(connectionItem.getProperty().getLabel());
properties.setDistribution(connection.getDistribution());
properties.setVersion(connection.getDfVersion());
properties.setUseKrb(connection.isEnableKerberos());
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.
the class HadoopClusterService method containedByCluster.
@Override
public boolean containedByCluster(Connection hadoopClusterConnection, Connection hadoopSubConnection) {
if (hadoopClusterConnection != null && hadoopSubConnection != null && hadoopClusterConnection instanceof HadoopClusterConnection) {
HadoopClusterConnection hcConnection = (HadoopClusterConnection) hadoopClusterConnection;
HadoopClusterConnection relativeHCConnection = HCRepositoryUtil.getRelativeHadoopClusterConnection(hadoopSubConnection);
if (hcConnection.equals(relativeHCConnection)) {
return true;
}
}
return false;
}
Aggregations