Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemment getInstance() method for all ConfigurationType to avoid reference to different ConfigurationType objects #2478

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ public CosmosSparkClusterOpsCtrl(@NotNull CosmosSparkClusterOps sparkServerlessC

final RunManager runManager = RunManager.getInstance(project);
final List<RunnerAndConfigurationSettings> batchConfigSettings = runManager
.getConfigurationSettingsList(findConfigurationType(CosmosSparkConfigurationType.class));
.getConfigurationSettingsList(CosmosSparkConfigurationType.getInstance());

final String runConfigName = "[Azure Data Lake Spark] " + cluster.getClusterNameWithAccountName();
final RunnerAndConfigurationSettings runConfigurationSetting = batchConfigSettings.stream()
.filter(settings -> settings.getConfiguration().getName().startsWith(runConfigName))
.findFirst()
.orElseGet(() -> runManager.createRunConfiguration(
runConfigName,
new CosmosSparkConfigurationFactory(findConfigurationType(CosmosSparkConfigurationType.class))));
new CosmosSparkConfigurationFactory(CosmosSparkConfigurationType.getInstance())));

context.putData(RUN_CONFIGURATION_SETTING, runConfigurationSetting)
.putData(CLUSTER, cluster);
Expand Down Expand Up @@ -169,15 +169,15 @@ public CosmosSparkClusterOpsCtrl(@NotNull CosmosSparkClusterOps sparkServerlessC

final RunManager runManager = RunManager.getInstance(project);
final List<RunnerAndConfigurationSettings> batchConfigSettings = runManager
.getConfigurationSettingsList(findConfigurationType(CosmosServerlessSparkConfigurationType.class));
.getConfigurationSettingsList(CosmosServerlessSparkConfigurationType.getInstance());

final String runConfigName = "[Cosmos Serverless Spark] " + adlAccount.getName();
final RunnerAndConfigurationSettings runConfigurationSetting = batchConfigSettings.stream()
.filter(settings -> settings.getConfiguration().getName().startsWith(runConfigName))
.findFirst()
.orElseGet(() -> runManager.createRunConfiguration(
runConfigName,
new CosmosServerlessSparkConfigurationFactory(new CosmosServerlessSparkConfigurationType())));
new CosmosServerlessSparkConfigurationFactory(CosmosServerlessSparkConfigurationType.getInstance())));

context.putData(RUN_CONFIGURATION_SETTING, runConfigurationSetting)
.putData(CLUSTER, adlAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract class RunSparkScalaConsoleAction
return
}

val batchConfigurationType = findConfigurationType(LivySparkBatchJobRunConfigurationType::class.java)
val batchConfigurationType = LivySparkBatchJobRunConfigurationType.getInstance()
val batchConfigSettings = runManagerEx.getConfigurationSettingsList(batchConfigurationType)

// Try to find one from the same type list
Expand Down Expand Up @@ -111,7 +111,7 @@ abstract class RunSparkScalaConsoleAction
}

override fun getMyConfigurationType(): LivySparkBatchJobRunConfigurationType? =
findConfigurationType(LivySparkBatchJobRunConfigurationType::class.java)
LivySparkBatchJobRunConfigurationType.getInstance()

override fun checkFile(psiFile: PsiFile): Boolean = psiFile is ScalaFile
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@

package com.microsoft.azure.hdinsight.spark.console

import com.intellij.execution.configurations.ConfigurationTypeUtil
import org.jetbrains.plugins.scala.console.ScalaConsoleConfigurationType
import org.jetbrains.plugins.scala.console.ScalaConsoleRunConfigurationFactory

class SparkScalaLivyConsoleConfigurationType : ScalaConsoleConfigurationType() {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(SparkScalaLivyConsoleConfigurationType::class.java) }
}
override fun confFactory(): ScalaConsoleRunConfigurationFactory = SparkScalaLivyConsoleRunConfigurationFactory(this)

override fun getDisplayName(): String = "Spark Livy Interactive Session Console(Scala)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@

package com.microsoft.azure.hdinsight.spark.console

import com.intellij.execution.configurations.ConfigurationTypeUtil
import org.jetbrains.plugins.scala.console.ScalaConsoleConfigurationType
import org.jetbrains.plugins.scala.console.ScalaConsoleRunConfigurationFactory

class SparkScalaLocalConsoleConfigurationType : ScalaConsoleConfigurationType() {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(SparkScalaLocalConsoleConfigurationType::class.java) }
}
override fun confFactory(): ScalaConsoleRunConfigurationFactory = SparkScalaLocalConsoleRunConfigurationFactory(this)

override fun getDisplayName(): String = "Spark Local Console(Scala)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,22 @@
package com.microsoft.azure.hdinsight.spark.run.configuration

import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.ConfigurationTypeUtil
import com.microsoft.azure.hdinsight.common.CommonConst
import com.microsoft.intellij.util.PluginUtil
import javax.swing.Icon

class ArisSparkConfigurationType : ConfigurationType {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(ArisSparkConfigurationType::class.java) }
}
override fun getIcon(): Icon {
// TODO: should use Aris config icon
return PluginUtil.getIcon(CommonConst.OpenSparkUIIconPath)
}

class ArisSparkConfigurationType : LivySparkBatchJobRunConfigurationType() {
override fun getDisplayName(): String {
return "Aris On Spark"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
package com.microsoft.azure.hdinsight.spark.run.configuration

import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.ConfigurationTypeUtil
import com.microsoft.azure.hdinsight.common.CommonConst
import com.microsoft.intellij.util.PluginUtil
import javax.swing.Icon

class CosmosServerlessSparkConfigurationType : ConfigurationType {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(CosmosServerlessSparkConfigurationType::class.java) }
}

override fun getIcon(): Icon {
// TODO: should use Cosmos Serverless icon
return PluginUtil.getIcon("/icons/${CommonConst.AZURE_SERVERLESS_SPARK_ROOT_ICON_PATH}")
}

override fun getConfigurationTypeDescription(): String {
return "Cosmos Serverless Spark Job Configuration"
}

class CosmosServerlessSparkConfigurationType : CosmosSparkConfigurationType() {
override fun getDisplayName(): String {
return "Cosmos Serverless Spark"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ package com.microsoft.azure.hdinsight.spark.run.configuration

import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.ConfigurationTypeUtil
import com.microsoft.azure.hdinsight.common.CommonConst
import com.microsoft.intellij.util.PluginUtil
import javax.swing.Icon

open class CosmosSparkConfigurationType : ConfigurationType {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(CosmosSparkConfigurationType::class.java) }
}

override fun getIcon(): Icon {
return PluginUtil.getIcon("/icons/${CommonConst.AZURE_SERVERLESS_SPARK_ROOT_ICON_PATH}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ package com.microsoft.azure.hdinsight.spark.run.configuration

import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.ConfigurationTypeUtil
import com.microsoft.azure.hdinsight.common.CommonConst
import com.microsoft.intellij.util.PluginUtil
import javax.swing.Icon

class SparkFailureTaskDebugConfigurationType : ConfigurationType {
companion object {
@JvmStatic
val instance by lazy { ConfigurationTypeUtil.findConfigurationType(SparkFailureTaskDebugConfigurationType::class.java) }
}

override fun getIcon(): Icon {
return PluginUtil.getIcon(CommonConst.SparkFailureTaskDebugIcon_13x_Path)
}
Expand Down