_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q22200
NomadScheduler.getTaskSpecRawDriver
train
Task getTaskSpecRawDriver(Task task, String taskName, int containerIndex) { String executorBinary = Context.executorBinary(this.clusterConfig); // get arguments for heron executor command String[] executorArgs = SchedulerUtils.executorCommandArgs( this.clusterConfig, this.runtimeConfig, NomadConstan...
java
{ "resource": "" }
q22201
NomadScheduler.getFetchCommand
train
static String getFetchCommand(Config localConfig, Config clusterConfig, Config runtime) { return String.format("%s -u %s -f . -m local -p %s -d %s", Context.downloaderBinary(clusterConfig), Runtime.topologyPackageUri(runtime).toString(), Context.heronConf(localConfig), Context.heronHome(clus...
java
{ "resource": "" }
q22202
GcsUploader.generateStorageObjectName
train
private static String generateStorageObjectName(String topologyName, String filename) { return String.format("%s/%s", topologyName, filename); }
java
{ "resource": "" }
q22203
GcsUploader.getDownloadUrl
train
private static String getDownloadUrl(String bucket, String objectName) { return String.format(GCS_URL_FORMAT, bucket, objectName); }
java
{ "resource": "" }
q22204
SlurmLauncher.setupWorkingDirectory
train
protected boolean setupWorkingDirectory() { // get the path of core release URI String coreReleasePackageURI = SlurmContext.corePackageUri(config); // form the target dest core release file name String coreReleaseFileDestination = Paths.get( topologyWorkingDirectory, "heron-core.tar.gz").toStri...
java
{ "resource": "" }
q22205
JVMMetrics.registerMetrics
train
public void registerMetrics(MetricsCollector metricsCollector) { SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton( SystemConfig.HERON_SYSTEM_CONFIG); int interval = (int) systemConfig.getHeronMetricsExportInterval().getSeconds(); metricsCollector.registerMetric("_...
java
{ "resource": "" }
q22206
JVMMetrics.updateBufferPoolMetrics
train
private void updateBufferPoolMetrics() { for (BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeanList) { String normalizedKeyName = bufferPoolMXBean.getName().replaceAll("[^\\w]", "-"); final ByteAmount memoryUsed = ByteAmount.fromBytes(bufferPoolMXBean.getMemoryUsed()); final ByteAmount totalCa...
java
{ "resource": "" }
q22207
JVMMetrics.updateMemoryPoolMetrics
train
private void updateMemoryPoolMetrics() { for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeanList) { String normalizedKeyName = memoryPoolMXBean.getName().replaceAll("[^\\w]", "-"); MemoryUsage peakUsage = memoryPoolMXBean.getPeakUsage(); if (peakUsage != null) { jvmPeakUsagePerMemory...
java
{ "resource": "" }
q22208
JVMMetrics.updateFdMetrics
train
private void updateFdMetrics() { if (osMbean instanceof com.sun.management.UnixOperatingSystemMXBean) { final com.sun.management.UnixOperatingSystemMXBean unix = (com.sun.management.UnixOperatingSystemMXBean) osMbean; fdCount.setValue(unix.getOpenFileDescriptorCount()); fdLimit.setValue...
java
{ "resource": "" }
q22209
AuroraCLIController.killJob
train
@Override public boolean killJob() { List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "killall")); auroraCmd.add(jobSpec); appendAuroraCommandOptions(auroraCmd, isVerbose); return runProcess(auroraCmd); }
java
{ "resource": "" }
q22210
AuroraCLIController.restart
train
@Override public boolean restart(Integer containerId) { List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "restart")); if (containerId != null) { auroraCmd.add(String.format("%s/%d", jobSpec, containerId)); } else { auroraCmd.add(jobSpec); } appendAuroraCommandOp...
java
{ "resource": "" }
q22211
AuroraCLIController.appendAuroraCommandOptions
train
private static void appendAuroraCommandOptions(List<String> auroraCmd, boolean isVerbose) { // Append verbose if needed if (isVerbose) { auroraCmd.add("--verbose"); } // Append batch size. // Note that we can not use "--no-batching" since "restart" command does not accept it. // So we pla...
java
{ "resource": "" }
q22212
PhysicalPlanProvider.getBoltNames
train
public List<String> getBoltNames(PhysicalPlan pp) { TopologyAPI.Topology localTopology = pp.getTopology(); ArrayList<String> boltNames = new ArrayList<>(); for (TopologyAPI.Bolt bolt : localTopology.getBoltsList()) { boltNames.add(bolt.getComp().getName()); } return boltNames; }
java
{ "resource": "" }
q22213
PhysicalPlanProvider.getSpoutNames
train
public List<String> getSpoutNames(PhysicalPlan pp) { TopologyAPI.Topology localTopology = pp.getTopology(); ArrayList<String> spoutNames = new ArrayList<>(); for (TopologyAPI.Spout spout : localTopology.getSpoutsList()) { spoutNames.add(spout.getComp().getName()); } return spoutNames; }
java
{ "resource": "" }
q22214
ConfigBuilder.buildConfig
train
public Config buildConfig(EcoTopologyDefinition topologyDefinition) throws IllegalArgumentException { Map<String, Object> configMap = topologyDefinition.getConfig(); Config config = new Config(); for (Map.Entry<String, Object> entry: configMap.entrySet()) { if (entry.getKey().equals(COMPONENT_...
java
{ "resource": "" }
q22215
TopologyUtils.verifyTopology
train
public static boolean verifyTopology(TopologyAPI.Topology topology) { if (!topology.hasName() || topology.getName().isEmpty()) { LOG.severe("Missing topology name"); return false; } if (topology.getName().contains(".") || topology.getName().contains("/")) { LOG.severe("Invalid topology nam...
java
{ "resource": "" }
q22216
TopologyUtils.getComponentCpuMapConfig
train
public static Map<String, Double> getComponentCpuMapConfig(TopologyAPI.Topology topology) throws RuntimeException { Map<String, String> configMap = getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_CPUMAP); Map<String, Double> cpuMap = new HashMap<>(); for (Map.Entry<String, String> e...
java
{ "resource": "" }
q22217
TopologyUtils.getComponentRamMapConfig
train
public static Map<String, ByteAmount> getComponentRamMapConfig(TopologyAPI.Topology topology) throws RuntimeException { Map<String, String> configMap = getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_RAMMAP); Map<String, ByteAmount> ramMap = new HashMap<>(); for (Map.Entry<String, S...
java
{ "resource": "" }
q22218
TopologyUtils.getComponentDiskMapConfig
train
public static Map<String, ByteAmount> getComponentDiskMapConfig(TopologyAPI.Topology topology) throws RuntimeException { Map<String, String> configMap = getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_DISKMAP); Map<String, ByteAmount> diskMap = new HashMap<>(); for (Map.Entry<String...
java
{ "resource": "" }
q22219
UpdateTopologyManager.updateTopology
train
public void updateTopology(final PackingPlans.PackingPlan existingProtoPackingPlan, final PackingPlans.PackingPlan proposedProtoPackingPlan) throws ExecutionException, InterruptedException, ConcurrentModificationException { String topologyName = Runtime.topologyName(runtime); ...
java
{ "resource": "" }
q22220
TopologyBuilder.setSpout
train
public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelismHint) { validateComponentName(id); SpoutDeclarer s = new SpoutDeclarer(id, spout, parallelismHint); spouts.put(id, s); return s; }
java
{ "resource": "" }
q22221
SkewDetector.detect
train
@Override public Collection<Symptom> detect(Collection<Measurement> measurements) { Collection<Symptom> result = new ArrayList<>(); MeasurementsTable metrics = MeasurementsTable.of(measurements).type(metricName); Instant now = context.checkpoint(); for (String component : metrics.uniqueComponents()) ...
java
{ "resource": "" }
q22222
LocalLauncher.launch
train
@Override public boolean launch(PackingPlan packing) { LOG.log(Level.FINE, "Launching topology for local cluster {0}", LocalContext.cluster(config)); // setup the working directory // mainly it downloads and extracts the heron-core-release and topology package if (!setupWorkingDirectoryAndExt...
java
{ "resource": "" }
q22223
MetricsCacheManager.start
train
public void start() throws Exception { // 1. Do prepare work // create an instance of state manager String statemgrClass = Context.stateManagerClass(config); LOG.info("Context.stateManagerClass " + statemgrClass); IStateManager statemgr; try { statemgr = ReflectionUtils.newInstance(statemg...
java
{ "resource": "" }
q22224
S3Uploader.generateS3Path
train
private String generateS3Path(String pathPrefixParent, String topologyName, String filename) { List<String> pathParts = new ArrayList<>(Arrays.asList(pathPrefixParent.split("/"))); pathParts.add(topologyName); pathParts.add(filename); return String.join("/", pathParts); }
java
{ "resource": "" }
q22225
Simulator.submitTopology
train
public void submitTopology(String name, Config heronConfig, HeronTopology heronTopology) { TopologyAPI.Topology topologyToRun = heronTopology. setConfig(heronConfig). setName(name). setState(TopologyAPI.TopologyState.RUNNING). getTopology(); if (!Topology...
java
{ "resource": "" }
q22226
Utils.getConfigBuilder
train
public static TopologyAPI.Config.Builder getConfigBuilder(Config config) { TopologyAPI.Config.Builder cBldr = TopologyAPI.Config.newBuilder(); Set<String> apiVars = config.getApiVars(); for (String key : config.keySet()) { if (key == null) { LOG.warning("ignore: null config key found"); ...
java
{ "resource": "" }
q22227
PackingPlan.getMaxContainerResources
train
public Resource getMaxContainerResources() { double maxCpu = 0; ByteAmount maxRam = ByteAmount.ZERO; ByteAmount maxDisk = ByteAmount.ZERO; for (ContainerPlan containerPlan : getContainers()) { Resource containerResource = containerPlan.getScheduledResource().or(containerPlan.getRequiredR...
java
{ "resource": "" }
q22228
PackingPlan.getComponentCounts
train
public Map<String, Integer> getComponentCounts() { Map<String, Integer> componentCounts = new HashMap<>(); for (ContainerPlan containerPlan : getContainers()) { for (InstancePlan instancePlan : containerPlan.getInstances()) { Integer count = 0; if (componentCounts.containsKey(instancePlan....
java
{ "resource": "" }
q22229
PackingPlan.getComponentRamDistribution
train
public String getComponentRamDistribution() { // Generate a map with the minimal RAM size for each component Map<String, ByteAmount> ramMap = new HashMap<>(); for (ContainerPlan containerPlan : this.getContainers()) { for (InstancePlan instancePlan : containerPlan.getInstances()) { ByteAmount ...
java
{ "resource": "" }
q22230
DexMaker.declare
train
public Code declare(MethodId<?, ?> method, int flags) { TypeDeclaration typeDeclaration = getTypeDeclaration(method.declaringType); if (typeDeclaration.methods.containsKey(method)) { throw new IllegalStateException("already declared: " + method); } int supportedFlags = Modif...
java
{ "resource": "" }
q22231
DexMaker.declare
train
public void declare(FieldId<?, ?> fieldId, int flags, Object staticValue) { TypeDeclaration typeDeclaration = getTypeDeclaration(fieldId.declaringType); if (typeDeclaration.fields.containsKey(fieldId)) { throw new IllegalStateException("already declared: " + fieldId); } int ...
java
{ "resource": "" }
q22232
DexMaker.generate
train
public byte[] generate() { if (outputDex == null) { DexOptions options = new DexOptions(); options.minSdkVersion = DexFormat.API_NO_EXTENDED_OPCODES; outputDex = new DexFile(options); } for (TypeDeclaration typeDeclaration : types.values()) { outp...
java
{ "resource": "" }
q22233
DexMaker.generateFileName
train
private String generateFileName() { int checksum = 1; Set<TypeId<?>> typesKeySet = types.keySet(); Iterator<TypeId<?>> it = typesKeySet.iterator(); int[] checksums = new int[typesKeySet.size()]; int i = 0; while (it.hasNext()) { TypeId<?> typeId = it.next();...
java
{ "resource": "" }
q22234
DexMaker.generateAndLoad
train
public ClassLoader generateAndLoad(ClassLoader parent, File dexCache) throws IOException { if (dexCache == null) { String property = System.getProperty("dexmaker.dexcache"); if (property != null) { dexCache = new File(property); } else { dexCac...
java
{ "resource": "" }
q22235
MockMethodDispatcher.get
train
public static MockMethodDispatcher get(String identifier, Object instance) { if (instance == INSTANCE) { // Avoid endless loop if ConcurrentHashMap was redefined to check for being a mock. return null; } else { return INSTANCE.get(identifier); } }
java
{ "resource": "" }
q22236
MockMethodDispatcher.set
train
public static void set(String identifier, Object advice) { INSTANCE.putIfAbsent(identifier, new MockMethodDispatcher(advice)); }
java
{ "resource": "" }
q22237
MockMethodAdvice.isOverridden
train
public boolean isOverridden(Object instance, Method origin) { Class<?> currentType = instance.getClass(); do { try { return !origin.equals(currentType.getDeclaredMethod(origin.getName(), origin.getParameterTypes())); } catch (NoSuchMethodE...
java
{ "resource": "" }
q22238
StaticMockitoSessionBuilder.spyStatic
train
@UnstableApi public <T> StaticMockitoSessionBuilder spyStatic(Class<T> clazz) { staticMockings.add(new StaticMocking<>(clazz, () -> Mockito.mock(clazz, withSettings() .defaultAnswer(CALLS_REAL_METHODS)))); return this; }
java
{ "resource": "" }
q22239
Constants.getConstant
train
static TypedConstant getConstant(Object value) { if (value == null) { return CstKnownNull.THE_ONE; } else if (value instanceof Boolean) { return CstBoolean.make((Boolean) value); } else if (value instanceof Byte) { return CstByte.make((Byte) value); } ...
java
{ "resource": "" }
q22240
ProxyBuilder.build
train
public T build() throws IOException { check(handler != null, "handler == null"); check(constructorArgTypes.length == constructorArgValues.length, "constructorArgValues.length != constructorArgTypes.length"); Class<? extends T> proxyClass = buildProxyClass(); Constructor<?...
java
{ "resource": "" }
q22241
ProxyBuilder.superMethodName
train
private static String superMethodName(Method method) { String returnType = method.getReturnType().getName(); return "super$" + method.getName() + "$" + returnType.replace('.', '_').replace('[', '_').replace(';', '_'); }
java
{ "resource": "" }
q22242
ProxyBuilder.getConstructorsToOverwrite
train
@SuppressWarnings("unchecked") private static <T> Constructor<T>[] getConstructorsToOverwrite(Class<T> clazz) { return (Constructor<T>[]) clazz.getDeclaredConstructors(); }
java
{ "resource": "" }
q22243
ProxyBuilder.generateCodeForReturnStatement
train
@SuppressWarnings({ "rawtypes", "unchecked" }) private static void generateCodeForReturnStatement(Code code, Class methodReturnType, Local localForResultOfInvoke, Local localOfMethodReturnType, Local aBoxedResult) { if (PRIMITIVE_TO_UNBOX_METHOD.containsKey(methodReturnType)) { code....
java
{ "resource": "" }
q22244
ExtendedMockito.staticMockMarker
train
@UnstableApi @SuppressWarnings("unchecked") public static <T> T staticMockMarker(Class<T> clazz) { for (StaticMockitoSession session : sessions) { T marker = session.staticMockMarker(clazz); if (marker != null) { return marker; } } ret...
java
{ "resource": "" }
q22245
ExtendedMockito.spyOn
train
@UnstableApi @SuppressWarnings("CheckReturnValue") public static void spyOn(Object toSpy) { if (onSpyInProgressInstance.get() != null) { throw new IllegalStateException("Cannot set up spying on an existing object while " + "setting up spying for another existing object");...
java
{ "resource": "" }
q22246
ExtendedMockito.verifyInt
train
@SuppressWarnings({"CheckReturnValue", "MockitoUsage", "unchecked"}) static void verifyInt(MockedVoidMethod method, VerificationMode mode, InOrder instanceInOrder) { if (onMethodCallDuringVerification.get() != null) { throw new IllegalStateException("Verification is already in progre...
java
{ "resource": "" }
q22247
InlineDexmakerMockMaker.getMethodsToProxy
train
private <T> Method[] getMethodsToProxy(MockCreationSettings<T> settings) { Set<MethodSetEntry> abstractMethods = new HashSet<>(); Set<MethodSetEntry> nonAbstractMethods = new HashSet<>(); Class<?> superClass = settings.getTypeToMock(); while (superClass != null) { for (Metho...
java
{ "resource": "" }
q22248
AnnotationId.get
train
public static <D, V> AnnotationId<D, V> get(TypeId<D> declaringType, TypeId<V> type, ElementType annotatedElement) { if (annotatedElement != ElementType.TYPE && annotatedElement != ElementType.METHOD && annotatedElement != ElementTy...
java
{ "resource": "" }
q22249
AnnotationId.set
train
public void set(Element element) { if (element == null) { throw new NullPointerException("element == null"); } CstString pairName = new CstString(element.getName()); Constant pairValue = Element.toConstant(element.getValue()); NameValuePair nameValuePair = new NameVa...
java
{ "resource": "" }
q22250
AnnotationId.addToMethod
train
public void addToMethod(DexMaker dexMaker, MethodId<?, ?> method) { if (annotatedElement != ElementType.METHOD) { throw new IllegalStateException("This annotation is not for method"); } if (!method.declaringType.equals(declaringType)) { throw new IllegalArgumentException...
java
{ "resource": "" }
q22251
Local.initialize
train
int initialize(int nextAvailableRegister) { this.reg = nextAvailableRegister; this.spec = RegisterSpec.make(nextAvailableRegister, type.ropType); return size(); }
java
{ "resource": "" }
q22252
JvmtiAgent.appendToBootstrapClassLoaderSearch
train
void appendToBootstrapClassLoaderSearch(InputStream jarStream) throws IOException { File jarFile = File.createTempFile("mockito-boot", ".jar"); jarFile.deleteOnExit(); byte[] buffer = new byte[64 * 1024]; try (OutputStream os = new FileOutputStream(jarFile)) { while (true) {...
java
{ "resource": "" }
q22253
StaticMockitoSession.mockStatic
train
<T> void mockStatic(StaticMocking<T> mocking) { if (ExtendedMockito.staticMockMarker(mocking.clazz) != null) { throw new IllegalArgumentException(mocking.clazz + " is already mocked"); } mockingInProgressClass.set(mocking.clazz); try { classToMarker.put(mocking.c...
java
{ "resource": "" }
q22254
Code.mark
train
public void mark(Label label) { adopt(label); if (label.marked) { throw new IllegalStateException("already marked"); } label.marked = true; if (currentLabel != null) { jump(label); // blocks must end with a branch, return or throw } current...
java
{ "resource": "" }
q22255
Code.splitCurrentLabel
train
private void splitCurrentLabel(Label alternateSuccessor, List<Label> catchLabels) { Label newLabel = new Label(); adopt(newLabel); currentLabel.primarySuccessor = newLabel; currentLabel.alternateSuccessor = alternateSuccessor; currentLabel.catchLabels = catchLabels; curre...
java
{ "resource": "" }
q22256
Code.cast
train
public void cast(Local<?> target, Local<?> source) { if (source.getType().ropType.isReference()) { addInstruction(new ThrowingCstInsn(Rops.CHECK_CAST, sourcePosition, RegisterSpecList.make(source.spec()), catches, target.type.constant)); moveResult(target, true); ...
java
{ "resource": "" }
q22257
Code.toBasicBlocks
train
BasicBlockList toBasicBlocks() { if (!localsInitialized) { initializeLocals(); } cleanUpLabels(); BasicBlockList result = new BasicBlockList(labels.size()); for (int i = 0; i < labels.size(); i++) { result.set(i, labels.get(i).toBasicBlock()); } ...
java
{ "resource": "" }
q22258
Code.cleanUpLabels
train
private void cleanUpLabels() { int id = 0; for (Iterator<Label> i = labels.iterator(); i.hasNext();) { Label label = i.next(); if (label.isEmpty()) { i.remove(); } else { label.compact(); label.id = id++; } ...
java
{ "resource": "" }
q22259
Checked.wrappedException
train
@SuppressWarnings("unchecked") private E wrappedException(final Exception exp) { E wrapped = new UncheckedFunc<>(this.func).apply(exp); final int level = new InheritanceLevel( exp.getClass(), wrapped.getClass() ).value(); final String message = wrapped.getMessage() ...
java
{ "resource": "" }
q22260
TailOf.copy
train
private int copy(final byte[] buffer, final byte[] response, final int read) { System.arraycopy( buffer, read - this.count, response, 0, this.count ); return new MinOf(this.count, read).intValue(); }
java
{ "resource": "" }
q22261
TailOf.copyPartial
train
private int copyPartial(final byte[] buffer, final byte[] response, final int num, final int read) { final int result; if (num > 0) { System.arraycopy( response, read, response, 0, this.count - read ); System.arraycopy(buffer, 0, response, this...
java
{ "resource": "" }
q22262
ScalarWithFallback.fallback
train
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes") private T fallback(final Throwable exp) throws Exception { final Sorted<Map.Entry<FallbackFrom<T>, Integer>> candidates = new Sorted<>( Comparator.comparing(Map.Entry::getValue), new Filtered<>( ...
java
{ "resource": "" }
q22263
WriterAsOutputStream.next
train
private int next(final byte[] buffer, final int offset, final int length) throws IOException { final int max = Math.min(length, this.input.remaining()); this.input.put(buffer, offset, max); this.input.flip(); while (true) { final CoderResult result = this.decoder.deco...
java
{ "resource": "" }
q22264
FallbackFrom.support
train
public Integer support(final Class<? extends Throwable> target) { return new MinOf( new Mapped<>( supported -> new InheritanceLevel(target, supported).value(), this.exceptions ) ).intValue(); }
java
{ "resource": "" }
q22265
InheritanceLevel.calculateLevel
train
private int calculateLevel() { int level = Integer.MIN_VALUE; Class<?> sclass = this.derived.getSuperclass(); int idx = 0; while (!sclass.equals(Object.class)) { idx += 1; if (sclass.equals(this.base)) { level = idx; break; ...
java
{ "resource": "" }
q22266
EnvUtil.convertTcpToHttpUrl
train
public static String convertTcpToHttpUrl(String connect) { String protocol = connect.contains(":" + DOCKER_HTTPS_PORT) ? "https:" : "http:"; return connect.replaceFirst("^tcp:", protocol); }
java
{ "resource": "" }
q22267
EnvUtil.greaterOrEqualsVersion
train
public static boolean greaterOrEqualsVersion(String versionA, String versionB) { String largerVersion = extractLargerVersion(versionA, versionB); return largerVersion != null && largerVersion.equals(versionA); }
java
{ "resource": "" }
q22268
EnvUtil.extractFromPropertiesAsMap
train
public static Map<String, String> extractFromPropertiesAsMap(String prefix, Properties properties) { Map<String, String> ret = new HashMap<>(); Enumeration names = properties.propertyNames(); String prefixP = prefix + "."; while (names.hasMoreElements()) { String propName = (...
java
{ "resource": "" }
q22269
EnvUtil.formatDurationTill
train
public static String formatDurationTill(long start) { long duration = System.currentTimeMillis() - start; StringBuilder res = new StringBuilder(); TimeUnit current = HOURS; while (duration > 0) { long temp = current.convert(duration, MILLISECONDS); if (temp > 0...
java
{ "resource": "" }
q22270
EnvUtil.firstRegistryOf
train
public static String firstRegistryOf(String ... checkFirst) { for (String registry : checkFirst) { if (registry != null) { return registry; } } // Check environment as last resort return System.getenv("DOCKER_REGISTRY"); }
java
{ "resource": "" }
q22271
EnvUtil.storeTimestamp
train
public static void storeTimestamp(File tsFile, Date buildDate) throws MojoExecutionException { try { if (tsFile.exists()) { tsFile.delete(); } File dir = tsFile.getParentFile(); if (!dir.exists()) { if (!dir.mkdirs()) { ...
java
{ "resource": "" }
q22272
KeyStoreUtil.createDockerKeyStore
train
public static KeyStore createDockerKeyStore(String certPath) throws IOException, GeneralSecurityException { PrivateKey privKey = loadPrivateKey(certPath + "/key.pem"); Certificate[] certs = loadCertificates(certPath + "/cert.pem"); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultTyp...
java
{ "resource": "" }
q22273
EcrExtendedAuth.extendedAuth
train
public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException, MojoExecutionException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAs...
java
{ "resource": "" }
q22274
AnsiLogger.progressStart
train
public void progressStart() { // A progress indicator is always written out to standard out if a tty is enabled. if (!batchMode && log.isInfoEnabled()) { imageLines.remove(); updateCount.remove(); imageLines.set(new HashMap<String, Integer>()); updateCount...
java
{ "resource": "" }
q22275
AnsiLogger.progressUpdate
train
public void progressUpdate(String layerId, String status, String progressMessage) { if (!batchMode && log.isInfoEnabled() && StringUtils.isNotEmpty(layerId)) { if (useAnsi) { updateAnsiProgress(layerId, status, progressMessage); } else { updateNonAnsiProgr...
java
{ "resource": "" }
q22276
AnsiLogger.format
train
private String format(String message, Object[] params) { if (params.length == 0) { return message; } else if (params.length == 1 && params[0] instanceof Throwable) { // We print only the message here since breaking exception will bubble up // anyway return...
java
{ "resource": "" }
q22277
ContainerTracker.registerContainer
train
public synchronized void registerContainer(String containerId, ImageConfiguration imageConfig, GavLabel gavLabel) { ContainerShutdownDescriptor descriptor = new ContainerShutdownDescriptor(imageConfig, containerId); ...
java
{ "resource": "" }
q22278
ContainerTracker.lookupContainer
train
public synchronized String lookupContainer(String lookup) { if (aliasToContainerMap.containsKey(lookup)) { return aliasToContainerMap.get(lookup); } return imageToContainerMap.get(lookup); }
java
{ "resource": "" }
q22279
ContainerTracker.removeShutdownDescriptors
train
public synchronized Collection<ContainerShutdownDescriptor> removeShutdownDescriptors(GavLabel gavLabel) { List<ContainerShutdownDescriptor> descriptors; if (gavLabel != null) { descriptors = removeFromPomLabelMap(gavLabel); removeFromPerContainerMap(descriptors); } else ...
java
{ "resource": "" }
q22280
AbstractDockerMojo.getBuildTimestamp
train
protected synchronized Date getBuildTimestamp() throws IOException { Date now = (Date) getPluginContext().get(CONTEXT_KEY_BUILD_TIMESTAMP); if (now == null) { now = getReferenceDate(); getPluginContext().put(CONTEXT_KEY_BUILD_TIMESTAMP,now); } return now; }
java
{ "resource": "" }
q22281
AbstractDockerMojo.getReferenceDate
train
protected Date getReferenceDate() throws IOException { Date referenceDate = EnvUtil.loadTimestamp(getBuildTimestampFile()); return referenceDate != null ? referenceDate : new Date(); }
java
{ "resource": "" }
q22282
AbstractDockerMojo.initImageConfiguration
train
private String initImageConfiguration(Date buildTimeStamp) { // Resolve images resolvedImages = ConfigHelper.resolveImages( log, images, // Unresolved images new ConfigHelper.Resolver() { @Override public List<...
java
{ "resource": "" }
q22283
DockerAccessFactory.getDefaultDockerHostProviders
train
private List<DockerConnectionDetector.DockerHostProvider> getDefaultDockerHostProviders(DockerAccessContext dockerAccessContext, Logger log) { DockerMachineConfiguration config = dockerAccessContext.getMachine(); if (dockerAccessContext.isSkipMachine()) { config = null; } else if (c...
java
{ "resource": "" }
q22284
DockerAccessFactory.setDockerHostAddressProperty
train
private void setDockerHostAddressProperty(DockerAccessContext dockerAccessContext, String dockerUrl) throws MojoFailureException { Properties props = dockerAccessContext.getProjectProperties(); if (props.getProperty("docker.host.address") == null) { final String host; try { ...
java
{ "resource": "" }
q22285
ConfigHelper.resolveImages
train
public static List<ImageConfiguration> resolveImages(Logger logger, List<ImageConfiguration> images, Resolver imageResolver, String imageNameFilter, ...
java
{ "resource": "" }
q22286
ConfigHelper.initAndValidate
train
public static String initAndValidate(List<ImageConfiguration> images, String apiVersion, NameFormatter nameFormatter, Logger log) { // Init and validate configs. After this step, getResolvedImages() contains the valid configuration. for (ImageConfiguration imageC...
java
{ "resource": "" }
q22287
ConfigHelper.matchesConfiguredImages
train
public static boolean matchesConfiguredImages(String imageList, ImageConfiguration imageConfig) { if (imageList == null) { return true; } Set<String> imagesAllowed = new HashSet<>(Arrays.asList(imageList.split("\\s*,\\s*"))); return imagesAllowed.contains(imageConfig.getName(...
java
{ "resource": "" }
q22288
ConfigHelper.filterImages
train
private static List<ImageConfiguration> filterImages(String nameFilter, List<ImageConfiguration> imagesToFilter) { List<ImageConfiguration> ret = new ArrayList<>(); for (ImageConfiguration imageConfig : imagesToFilter) { if (matchesConfiguredImages(nameFilter, imageConfig)) { ...
java
{ "resource": "" }
q22289
ConfigHelper.resolveConfiguration
train
private static List<ImageConfiguration> resolveConfiguration(Resolver imageResolver, List<ImageConfiguration> unresolvedImages) { List<ImageConfiguration> ret = new ArrayList<>(); if (unresolvedImages != null) { for (ImageConfi...
java
{ "resource": "" }
q22290
ConfigHelper.verifyImageNames
train
private static void verifyImageNames(List<ImageConfiguration> ret) { for (ImageConfiguration config : ret) { if (config.getName() == null) { throw new IllegalArgumentException("Configuration error: <image> must have a non-null <name>"); } } }
java
{ "resource": "" }
q22291
MojoExecutionService.callPluginGoal
train
public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException { String[] parts = splitGoalSpec(fullGoal); Plugin plugin = project.getPlugin(parts[0]); String goal = parts[1]; if (plugin == null) { throw new MojoFailureException("No goal " + ...
java
{ "resource": "" }
q22292
DockerFileBuilder.write
train
public File write(File destDir) throws IOException { File target = new File(destDir,"Dockerfile"); FileUtils.fileWrite(target, content()); return target; }
java
{ "resource": "" }
q22293
DockerFileBuilder.createKeyValue
train
private String createKeyValue(String key, String value) { StringBuilder sb = new StringBuilder(); // no quoting the key; "Keys are alphanumeric strings which may contain periods (.) and hyphens (-)" sb.append(key).append('='); if (value == null || value.isEmpty()) { return sb...
java
{ "resource": "" }
q22294
DockerFileBuilder.run
train
public DockerFileBuilder run(List<String> runCmds) { if (runCmds != null) { for (String cmd : runCmds) { if (!StringUtils.isEmpty(cmd)) { this.runCmds.add(cmd); } } } return this; }
java
{ "resource": "" }
q22295
ContainerNamingUtil.getContainersToStop
train
public static Collection<Container> getContainersToStop(final ImageConfiguration image, final String defaultContainerNamePattern, final Date buildTimestamp, ...
java
{ "resource": "" }
q22296
RegistryService.pushImages
train
public void pushImages(Collection<ImageConfiguration> imageConfigs, int retries, RegistryConfig registryConfig, boolean skipTag) throws DockerAccessException, MojoExecutionException { for (ImageConfiguration imageConfig : imageConfigs) { BuildImageConfiguration buildConfig...
java
{ "resource": "" }
q22297
BuildImageConfiguration.initDockerFileFile
train
private void initDockerFileFile(Logger log) { // can't have dockerFile/dockerFileDir and dockerArchive if ((dockerFile != null || dockerFileDir != null) && dockerArchive != null) { throw new IllegalArgumentException("Both <dockerFile> (<dockerFileDir>) and <dockerArchive> are set. " + ...
java
{ "resource": "" }
q22298
DockerAssemblyManager.createBuildTarBall
train
private File createBuildTarBall(BuildDirs buildDirs, List<ArchiverCustomizer> archiverCustomizers, AssemblyConfiguration assemblyConfig, ArchiveCompression compression) throws MojoExecutionException { File archive = new File(buildDirs.getTemporaryRootDirectory(), "docker-buil...
java
{ "resource": "" }
q22299
DockerAssemblyManager.ensureThatArtifactFileIsSet
train
private File ensureThatArtifactFileIsSet(MavenProject project) { Artifact artifact = project.getArtifact(); if (artifact == null) { return null; } File oldFile = artifact.getFile(); if (oldFile != null) { return oldFile; } Build build = pro...
java
{ "resource": "" }