id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
223551095_2112 | @Override
public InputStream readFrom(String spec, String requestMethod, String body, Map<String, String> headers)
throws IOException {
return getInputStream(spec, requestMethod, headers, body == null ? null : body.getBytes());
} |
223551095_2113 | @Override
public InputStream readAs(String spec, String requestMethod, String body, Map<String, String> headers,
String userName)
throws IOException {
return readFrom(addDoAs(spec, userName), requestMethod, body, headers);
} |
223551095_2114 | @Override
public InputStream readAsCurrent(String spec, String requestMethod, String body, Map<String, String> headers)
throws IOException {
return readAs(spec, requestMethod, body, headers, viewContext.getUsername());
} |
223551095_2115 | @Override
public HttpURLConnection getConnection(String spec,
String requestMethod,
String body,
Map<String, String> headers) throws IOException {
return getHttpURLConnection(spec, requestMethod, heade... |
223551095_2116 | @Override
public HttpURLConnection getConnectionAs(String spec,
String requestMethod,
String body,
Map<String, String> headers,
String userName) throws IOEx... |
223551095_2117 | @Override
public HttpURLConnection getConnectionAsCurrent(String spec,
String requestMethod,
String body,
Map<String, String> headers) throws IOException {
return getConnecti... |
223551095_2122 | public Set<SubResourceDefinition> getSubResourceDefinitions(
String viewName, String version) {
viewName = ViewEntity.getViewName(viewName, version);
return subResourceDefinitionsMap.get(viewName);
} |
223551095_2123 | public void addInstanceDefinition(ViewEntity definition, ViewInstanceEntity instanceDefinition) {
Map<String, ViewInstanceEntity> instanceDefinitions = viewInstanceDefinitions.get(definition);
if (instanceDefinitions == null) {
instanceDefinitions = new HashMap<>();
viewInstanceDefinitions.put(definition, i... |
223551095_2124 | public void installViewInstance(ViewInstanceEntity instanceEntity)
throws ValidationException, IllegalArgumentException, SystemException {
ViewEntity viewEntity = getDefinition(instanceEntity.getViewName());
if (viewEntity != null) {
String instanceName = instanceEntity.getName();
String viewName = view... |
223551095_2126 | public void setViewInstanceProperties(ViewInstanceEntity instanceEntity, Map<String, String> properties,
ViewConfig viewConfig, ClassLoader classLoader) throws SystemException {
try {
Masker masker = getMasker(viewConfig.getMaskerClass(classLoader));
Map<String, Parameter... |
223551095_2127 | @Transactional
public void uninstallViewInstance(ViewInstanceEntity instanceEntity) throws IllegalStateException {
try {
viewInstanceOperationHandler.uninstallViewInstance(instanceEntity);
updateCaches(instanceEntity);
} catch (IllegalStateException illegalStateExcpetion) {
LOG.error("Exception occurred... |
223551095_2130 | protected static boolean extractViewArchive(String archivePath, ViewModule viewModule, boolean systemOnly)
throws Exception {
Injector injector = Guice.createInjector(viewModule);
ViewExtractor extractor = injector.getInstance(ViewExtractor.class);
ViewArchiveUtility archiveUtility = injector.getInstance(View... |
223551095_2132 | public ClassLoader extractViewArchive(ViewEntity view, File viewArchive, File archiveDir, List<File> viewsAdditionalClasspath)
throws ExtractionException {
String archivePath = archiveDir.getAbsolutePath();
try {
// Remove directory if jar was updated since last extracting
if (archiveDir.exists() && vie... |
223551095_2133 | public boolean ensureExtractedArchiveDirectory(String extractedArchivesPath) {
File extractedArchiveDir = archiveUtility.getFile(extractedArchivesPath);
return extractedArchiveDir.exists() || extractedArchiveDir.mkdir();
} |
223551095_2138 | public static Result mkdir(String directoryPath, boolean sudo) throws IOException, InterruptedException {
// If this directory already exists, do not try to create it
if (pathExists(directoryPath, sudo).isSuccessful()) {
return new Result(0, "The directory already exists, skipping.", ""); // Success!
} else {... |
223551095_2139 | public static Result copyFile(String srcFile, String destFile, boolean force, boolean sudo) throws IOException, InterruptedException {
ArrayList<String> command = new ArrayList<>();
if (WINDOWS) {
command.add("copy");
if (force) {
command.add("/Y"); // force overwrite
}
} else {
command.add(... |
223551095_2147 | public boolean isRunning() {
return !isStopped;
} |
223551095_2148 | public void start() {
pauseLock.lock();
try {
isStopped = false;
unpaused.signalAll();
} finally {
pauseLock.unlock();
}
} |
223551095_2152 | public static <T> List<Set<T>> split(Set<T> original, int subsetSize) {
if(subsetSize <= 0) {
throw new IllegalArgumentException("Incorrect max size");
}
if(original == null || original.isEmpty()) {
return Collections.emptyList();
}
int subsetCount = (int) (Math.ceil((double)original.size() / subsetSi... |
223551095_2153 | public String readPassword(String passwordProperty, String defaultPassword) {
if (StringUtils.isNotBlank(passwordProperty)) {
if (CredentialProvider.isAliasString(passwordProperty)) {
return readPasswordFromStore(passwordProperty);
} else {
final String pw = readPasswordFromFile(passwordProperty, ... |
223551095_2154 | public String readPassword(String passwordProperty, String defaultPassword) {
if (StringUtils.isNotBlank(passwordProperty)) {
if (CredentialProvider.isAliasString(passwordProperty)) {
return readPasswordFromStore(passwordProperty);
} else {
final String pw = readPasswordFromFile(passwordProperty, ... |
223551095_2155 | public String readPassword(String passwordProperty, String defaultPassword) {
if (StringUtils.isNotBlank(passwordProperty)) {
if (CredentialProvider.isAliasString(passwordProperty)) {
return readPasswordFromStore(passwordProperty);
} else {
final String pw = readPasswordFromFile(passwordProperty, ... |
223551095_2156 | public String readPassword(String passwordProperty, String defaultPassword) {
if (StringUtils.isNotBlank(passwordProperty)) {
if (CredentialProvider.isAliasString(passwordProperty)) {
return readPasswordFromStore(passwordProperty);
} else {
final String pw = readPasswordFromFile(passwordProperty, ... |
223551095_2157 | public String readPassword(String passwordProperty, String defaultPassword) {
if (StringUtils.isNotBlank(passwordProperty)) {
if (CredentialProvider.isAliasString(passwordProperty)) {
return readPasswordFromStore(passwordProperty);
} else {
final String pw = readPasswordFromFile(passwordProperty, ... |
223551095_2158 | public static String getRemoteAddress(HttpServletRequest request) {
String ip = null;
for (String header : headersToCheck) {
ip = request.getHeader(header);
if (!isRemoteAddressUnknown(ip)) {
break;
}
}
if (isRemoteAddressUnknown(ip)) {
ip = request.getRemoteAddr();
}
if (containsMulti... |
223551095_2159 | public static String getRemoteAddress(HttpServletRequest request) {
String ip = null;
for (String header : headersToCheck) {
ip = request.getHeader(header);
if (!isRemoteAddressUnknown(ip)) {
break;
}
}
if (isRemoteAddressUnknown(ip)) {
ip = request.getRemoteAddr();
}
if (containsMulti... |
223551095_2160 | public static String getRemoteAddress(HttpServletRequest request) {
String ip = null;
for (String header : headersToCheck) {
ip = request.getHeader(header);
if (!isRemoteAddressUnknown(ip)) {
break;
}
}
if (isRemoteAddressUnknown(ip)) {
ip = request.getRemoteAddr();
}
if (containsMulti... |
223551095_2161 | public static String getRemoteAddress(HttpServletRequest request) {
String ip = null;
for (String header : headersToCheck) {
ip = request.getHeader(header);
if (!isRemoteAddressUnknown(ip)) {
break;
}
}
if (isRemoteAddressUnknown(ip)) {
ip = request.getRemoteAddr();
}
if (containsMulti... |
223551095_2162 | public static MultiValueMap<String, String> getQueryStringParameters(HttpServletRequest request) {
// Manually parse the query string rather than use HttpServletRequest#getParameter so that
// the message body remains intact and available. Calling HttpServletRequest#getParameter
// could interfere with processin... |
223551095_2163 | public static List<String> getQueryStringParameterValues(HttpServletRequest request, String parameterName) {
MultiValueMap<String, String> valueMap = getQueryStringParameters(request);
return ((valueMap == null) || !valueMap.containsKey(parameterName))
? null
: valueMap.get(parameterName);
} |
223551095_2164 | public static String getQueryStringParameterValue(HttpServletRequest request, String parameterName) {
MultiValueMap<String, String> valueMap = getQueryStringParameters(request);
return ((valueMap == null) || !valueMap.containsKey(parameterName))
? null
: valueMap.getFirst(parameterName);
} |
223551095_2165 | public static String jaxbToString(Object jaxbObj) throws JAXBException,
JsonGenerationException, JsonMappingException, IOException {
return getGson().toJson(jaxbObj);
} |
223551095_2166 | public static Map<String, Set<String>> getClusterHostInfo(Cluster cluster) throws AmbariException {
//Fill hosts and ports lists
Set<String> hostsSet = new LinkedHashSet<>();
List<Integer> portsList = new ArrayList<>();
List<String> rackList = new ArrayList<>();
List<String> ipV4List = new ArrayList<>(... |
223551095_2167 | public static void useAmbariJdkInCommandParams(Map<String, String> commandParams, Configuration configuration) {
if (StringUtils.isNotEmpty(configuration.getJavaHome()) && !configuration.getJavaHome().equals(configuration.getStackJavaHome())) {
commandParams.put(AMBARI_JAVA_HOME, configuration.getJavaHome());
... |
223551095_2168 | public static void useAmbariJdkInCommandParams(Map<String, String> commandParams, Configuration configuration) {
if (StringUtils.isNotEmpty(configuration.getJavaHome()) && !configuration.getJavaHome().equals(configuration.getStackJavaHome())) {
commandParams.put(AMBARI_JAVA_HOME, configuration.getJavaHome());
... |
223551095_2169 | public static void useAmbariJdkInCommandParams(Map<String, String> commandParams, Configuration configuration) {
if (StringUtils.isNotEmpty(configuration.getJavaHome()) && !configuration.getJavaHome().equals(configuration.getStackJavaHome())) {
commandParams.put(AMBARI_JAVA_HOME, configuration.getJavaHome());
... |
223551095_2170 | public static void useStackJdkIfExists(Map<String, String> hostLevelParams, Configuration configuration) {
// set defaults first
hostLevelParams.put(JAVA_HOME, configuration.getJavaHome());
hostLevelParams.put(JDK_NAME, configuration.getJDKName());
hostLevelParams.put(JCE_NAME, configuration.getJCEName());
ho... |
223551095_2171 | public static void useStackJdkIfExists(Map<String, String> hostLevelParams, Configuration configuration) {
// set defaults first
hostLevelParams.put(JAVA_HOME, configuration.getJavaHome());
hostLevelParams.put(JDK_NAME, configuration.getJDKName());
hostLevelParams.put(JCE_NAME, configuration.getJCEName());
ho... |
223551095_2172 | public static void useStackJdkIfExists(Map<String, String> hostLevelParams, Configuration configuration) {
// set defaults first
hostLevelParams.put(JAVA_HOME, configuration.getJavaHome());
hostLevelParams.put(JDK_NAME, configuration.getJDKName());
hostLevelParams.put(JCE_NAME, configuration.getJCEName());
ho... |
223551095_2173 | @Subscribe
@Transactional
public void onServiceEvent(ServiceInstalledEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug(event.toString());
}
try {
Cluster cluster = clusters.get().getClusterById(event.getClusterId());
Map<String, ServiceComponent> serviceComponents = cluster.getService(event.getServ... |
223551095_2174 | @Subscribe
@Transactional
public void onServiceComponentEvent(ServiceComponentInstalledEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug(event.toString());
}
m_lock.lock();
try {
Cluster cluster = clusters.get().getClusterById(event.getClusterId());
List<HostVersionEntity> hostVersionEntities =
... |
223551095_2175 | @Subscribe
@Transactional
public void onHostEvent(HostsAddedEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug(event.toString());
}
// create host version entries for every repository
@Experimental(feature=ExperimentalFeature.PATCH_UPGRADES, comment="Eventually take into account deleted repositories")
L... |
223551095_2176 | @Subscribe
public void onAmbariEvent(HostComponentVersionAdvertisedEvent event) throws AmbariException {
LOG.debug("Received event {}", event);
Cluster cluster = event.getCluster();
ServiceComponentHost sch = event.getServiceComponentHost();
String newVersion = event.getVersion();
if (StringUtils.isEmpty(newV... |
223551095_2177 | @Subscribe
public void onAmbariEvent(HostComponentVersionAdvertisedEvent event) throws AmbariException {
LOG.debug("Received event {}", event);
Cluster cluster = event.getCluster();
ServiceComponentHost sch = event.getServiceComponentHost();
String newVersion = event.getVersion();
if (StringUtils.isEmpty(newV... |
223551095_2178 | @Subscribe
public void onAmbariEvent(HostComponentVersionAdvertisedEvent event) throws AmbariException {
LOG.debug("Received event {}", event);
Cluster cluster = event.getCluster();
ServiceComponentHost sch = event.getServiceComponentHost();
String newVersion = event.getVersion();
if (StringUtils.isEmpty(newV... |
223551095_2179 | @Subscribe
public void onTaskUpdateEvent(TaskUpdateEvent event) {
LOG.debug("Received task update event {}", event);
List<HostRoleCommand> hostRoleCommandListAll = event.getHostRoleCommands();
List<HostRoleCommand> hostRoleCommandWithReceivedStatus = new ArrayList<>();
Set<StageEntityPK> stagesWithReceivedTas... |
223551095_2181 | public void scheduleBatch(RequestExecution requestExecution)
throws AmbariException {
if (!isSchedulerAvailable()) {
throw new AmbariException("Scheduler unavailable.");
}
// Check if scheduler is running, if not start immediately before scheduling jobs
try {
if (!executionScheduler.isSchedulerStarted... |
223551095_2182 | public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException {
if (!isSchedulerAvailable()) {
throw new AmbariException("Scheduler unavailable.");
}
// Delete all jobs for this request execution
Batch batch = requestExecution.getBatch();
if (batch != null) {
List<BatchRequest> b... |
223551095_2183 | public Long executeBatchRequest(long executionId,
long batchId,
String clusterName) throws AmbariException {
String type = null;
String uri = null;
String body = null;
try {
RequestExecution requestExecution = clusters.getCluster(clusterName).g... |
223551095_2184 | public void updateBatchRequest(long executionId, long batchId, String clusterName,
BatchRequestResponse batchRequestResponse,
boolean statusOnly) throws AmbariException {
Cluster cluster = clusters.getCluster(clusterName);
RequestExecution requestExecuti... |
223551095_2186 | public boolean hasToleranceThresholdExceeded(Long executionId,
String clusterName, Map<String, Integer> taskCounts) throws AmbariException {
Cluster cluster = clusters.getCluster(clusterName);
RequestExecution requestExecution = cluster.getAllRequestExecutions().get(executionId);
if (requestExecution == null)... |
223551095_2187 | public void finalizeBatch(long executionId, String clusterName)
throws AmbariException {
Cluster cluster = clusters.getCluster(clusterName);
RequestExecution requestExecution = cluster.getAllRequestExecutions().get(executionId);
if (requestExecution == null) {
throw new AmbariException("Unable to find reque... |
223551095_2188 | public boolean continueOnMisfire(JobExecutionContext jobExecutionContext) {
if (jobExecutionContext != null) {
Date scheduledTime = jobExecutionContext.getScheduledFireTime();
Long diff = DateUtils.getDateDifferenceInMinutes(scheduledTime);
return (diff < configuration.getExecutionSchedulerMisfireTolerati... |
223551095_2189 | protected WebResource extendApiResource(WebResource webResource, String relativeUri) {
WebResource result = webResource;
if (StringUtils.isNotEmpty(relativeUri) && !CONTAINS_API_VERSION_PATTERN.matcher(relativeUri).matches()) {
result = webResource.path(DEFAULT_API_PATH);
}
return result.path(relativeUri);
... |
223551095_2190 | public String getName() {
return name;
} |
223551095_2191 | public synchronized String getCommonName() {
if (commonName == null) {
// Strip version from the internal name
commonName = name.replaceAll("\\{(.+)\\}", "");
}
return commonName;
} |
223551095_2192 | @Override
public String getLabel() {
return label;
} |
223551095_2193 | @Override
public String getVersion() {
return version;
} |
223551095_2194 | @Override
public String getBuild() {
return build;
} |
223551095_2195 | public String getIcon() {
return icon;
} |
223551095_2196 | public String getIcon64() {
return icon64;
} |
223551095_2197 | public boolean isClusterConfigurable() {
return clusterConfigurable;
} |
223551095_2198 | public String getAmbariProperty(String key) {
return ambariConfiguration.getProperty(key);
} |
223551095_2199 | public ClassLoader getClassLoader() {
return classLoader;
} |
223551095_2200 | public String getArchive() {
return archive;
} |
223551095_2201 | public Configuration getAmbariConfiguration() {
return ambariConfiguration;
} |
223551095_2202 | public boolean isDeployed() {
return status.equals(ViewStatus.DEPLOYED);
} |
223551095_2203 | public void removePrivilege(PrivilegeEntity privilege) {
privileges.remove(privilege);
} |
223551095_2210 | public void setCustomCommandName(String customCommandName) {
this.customCommandName = customCommandName;
} |
223551095_2211 | public void setCommandDetail(String commandDetail) {
String truncatedCommandDetail = commandDetail;
if (commandDetail != null) {
if (commandDetail.length() > MAX_COMMAND_DETAIL_LENGTH) {
truncatedCommandDetail = commandDetail.substring(0, MAX_COMMAND_DETAIL_LENGTH) + "...";
}
}
this.commandDetail ... |
223551095_2212 | public void setOpsDisplayName(String opsDisplayName) {
this.opsDisplayName = opsDisplayName;
} |
223551095_2213 | public PrincipalType getPrincipalType() {
return principalType;
} |
223551095_2214 | public SyncType getSyncType() {
return syncType;
} |
223551095_2215 | public List<String> getPrincipalNames() {
return principalNames;
} |
223551095_2217 | public ViewEntity getViewEntity() {
return view;
} |
223551095_2218 | public InstanceConfig getConfiguration() {
return instanceConfig;
} |
223551095_2219 | public String getName() {
return name;
} |
223551095_2220 | @Override
public String getLabel() {
return label;
} |
223551095_2221 | @Override
public String getDescription() {
return description;
} |
223551095_2222 | @Override
public boolean isVisible() {
return visible == 'y' || visible == 'Y';
} |
223551095_2223 | public String getIcon() {
return icon;
} |
223551095_2224 | public boolean alterNames() {
return alterNames == 1;
} |
223551095_2225 | public String getIcon64() {
return icon64;
} |
223551095_2226 | public String getContextPath() {
return getContextPath(view.getCommonName(), view.getVersion(), getName());
} |
223551095_2227 | public void validate(ViewEntity viewEntity, Validator.ValidationContext context) throws ValidationException {
InstanceValidationResultImpl result = getValidationResult(viewEntity, context);
if (!result.isValid()) {
throw new ValidationException(result.toJson());
}
} |
223551095_2228 | public InstanceValidationResultImpl getValidationResult(ViewEntity viewEntity, Validator.ValidationContext context)
throws IllegalStateException {
Map<String, ValidationResult> propertyResults = new HashMap<>();
if (context.equals(Validator.ValidationContext.PRE_CREATE) ||
context.equals(Validator.Validat... |
223551095_2229 | public Collection<HostComponentDesiredStateEntity> getHostComponentDesiredStateEntities() {
return Collections.unmodifiableCollection(hostComponentDesiredStateEntities);
} |
223551095_2230 | public void addHostComponentDesiredStateEntity(HostComponentDesiredStateEntity stateEntity) {
hostComponentDesiredStateEntities.add(stateEntity);
} |
223551095_2231 | public void removeHostComponentDesiredStateEntity(HostComponentDesiredStateEntity stateEntity) {
hostComponentDesiredStateEntities.remove(stateEntity);
} |
223551095_2232 | public Collection<HostComponentStateEntity> getHostComponentStateEntities() {
return Collections.unmodifiableCollection(hostComponentStateEntities);
} |
223551095_2233 | public void addHostComponentStateEntity(HostComponentStateEntity stateEntity) {
hostComponentStateEntities.add(stateEntity);
} |
223551095_2234 | public void removeHostComponentStateEntity(HostComponentStateEntity stateEntity) {
hostComponentStateEntities.remove(stateEntity);
} |
223551095_2235 | @Override
@Transactional
public void create(RepositoryVersionEntity entity){
super.create(entity);
} |
223551095_2236 | @RequiresSession
public RepositoryVersionEntity findByDisplayName(String displayName) {
// TODO, this assumes that the display name is unique, but neither the code nor the DB schema enforces this.
final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery("repositoryVersionByDisp... |
223551095_2237 | @RequiresSession
public RepositoryVersionEntity findByStackAndVersion(StackId stackId,
String version) {
return findByStackNameAndVersion(stackId.getStackName(), version);
} |
223551095_2238 | @RequiresSession
public List<RepositoryVersionEntity> findByStack(StackId stackId) {
final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery("repositoryVersionByStack", RepositoryVersionEntity.class);
query.setParameter("stackName", stackId.getStackName());
query.setParamete... |
223551095_2239 | @RequiresSession
public RepositoryVersionEntity findByStackAndVersion(StackId stackId,
String version) {
return findByStackNameAndVersion(stackId.getStackName(), version);
} |
223551095_2240 | @RequiresSession
public List<RepositoryVersionEntity> findByStackAndType(StackId stackId, RepositoryType type) {
final TypedQuery<RepositoryVersionEntity> query = entityManagerProvider.get().createNamedQuery(
"repositoryVersionByStackAndType", RepositoryVersionEntity.class);
query.setParameter("stackName", st... |
223551095_2241 | @Transactional
public void create(HostConfigMapping hostConfigMapping) {
populateCache();
//create in db
entityManagerProvider.get().persist(buildHostConfigMappingEntity(hostConfigMapping));
//create in cache
Long hostId = hostConfigMapping.getHostId();
if (hostId != null) {
Set<HostConfigMapping>... |
223551095_2242 | @RequiresSession
public Set<HostConfigMapping> findByType(final long clusterId, Long hostId, final String type) {
populateCache();
if (!hostConfigMappingByHost.containsKey(hostId))
return Collections.emptySet();
Set<HostConfigMapping> set = new HashSet<>(hostConfigMappingByHost.get(hostId));
Col... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.