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

CodeWhisperer Start Button not available in the Developer Tools Tab #3684

Open
manodnyab opened this issue May 19, 2023 · 1 comment
Open
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.

Comments

@manodnyab
Copy link
Contributor

Issue: CodeWhisperer Start Button not available in the Developer Tools Tab

The CodeWhisperer documentation lists a Start Node to Get Started, however the CodeWhisperer Node in the Toolkit has the following options:

image (3)(2)

Solution:

If you see the above issue, please:
  • Upgrade to the latest version of the JetBrains IDE(minimum version 2022.2) then
  • Install the latest version of the Toolkit

Cause:

  • CodeWhisperer is now publicly available and is not in preview.
  • The AWS Toolkit for JetBrains removed the support for Preview Access Code for CodeWhisperer and introduced accessing CodeWhisperer through AWS Builder ID and AWS IAM Identity Center starting Toolkit version 1.54.
  • From this version onwards customers can access CodeWhisperer using AWS IAM Identity Center or AWS Builder ID by clicking on the Start Button in the CodeWhisperer node
  • Getting started : Setting up CodeWhisperer for individual developers - CodeWhisperer
Screen Shot 2023-05-19 at 9 04 57 AM
@manodnyab manodnyab added the guidance General information and guidance, answers to FAQs, or recommended best practices/resources. label May 19, 2023
@manodnyab manodnyab pinned this issue May 19, 2023
@liyifan77777
Copy link

public void validate(DatabaseConfig databaseConfig) {
try {
if(databaseConfig.getDriver().equals(EnumDriver.MONGODB.getCode())){
ProcessBuilder processBuilder = new ProcessBuilder();
String mongoShellV4Path = System.getProperty(MongoShellPathProperty.MONGO_SHELL_PATH_V4);
//根据密码是否为空去判断是否走验证。
String parsedCommand = "db.version()";
String connectUrl = "";
if(EmptyUtil.isNotEmpty(databaseConfig.getValidateType())){
EnumMongoDbValidateType enumMongoDbValidateType = EnumMongoDbValidateType.valueOf(databaseConfig.getValidateType().toUpperCase(Locale.ROOT));
switch (enumMongoDbValidateType){
case NONE:
connectUrl = mongoShellV4Path+" &&./mongo "+ databaseConfig.getDbUrl()+"/" + databaseConfig.getDbName() +" --quiet --eval " +"'"+parsedCommand + "'";
break;
case PASSWORD:
if(EmptyUtil.isNotEmpty(databaseConfig.getUsername()) && EmptyUtil.isNotEmpty(databaseConfig.getPassword())){
connectUrl = mongoShellV4Path+"&&./mongo "+ databaseConfig.getDbUrl()+"/" + databaseConfig.getDbName() +" --authenticationDatabase "+ databaseConfig.getDbName() +" -u "+ databaseConfig.getUsername() +" -p "+ databaseConfig.getPassword() +" --quiet --eval "+ "'"+parsedCommand + "'";
}
break;
case LDAP:
if(EmptyUtil.isNotEmpty(databaseConfig.getUsername()) && EmptyUtil.isNotEmpty(databaseConfig.getPassword())){
connectUrl = mongoShellV4Path+"&&./mongo "+ databaseConfig.getDbUrl()+"/" + databaseConfig.getDbName() +" --authenticationDatabase "+ databaseConfig.getDbName() +" -u "+ databaseConfig.getUsername() +" -p "+ databaseConfig.getPassword() +" --authenticationMechanism PLAIN --quiet --eval "+ "'"+parsedCommand + "'";
}
break;
default:
log.error("未查询到验证的类型");
}
}
log.warn("[nosql-mongo]:执行命令的连接字符串为:{}",connectUrl);

            processBuilder.command("bash", "-c", "cd "+connectUrl );
            Process process = processBuilder.start();
            InputStream inputStream = process.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            StringBuilder resultBuilder = new StringBuilder();
            String line;
            while ((line = bufferedReader.readLine()) != null ){
                resultBuilder.append(line);
            }
            int exitCode = process.waitFor();
            if(exitCode != 0){
                TIException.throwException(resultBuilder.toString());
            }
            return;
        }
        if(databaseConfig.getDriver().equals(EnumDriver.HBASE.getCode())){


            //添加hosts
            if(EmptyUtil.isNotEmpty(databaseConfig.getHosts())){
                DnsCacheManipulatorUtils.addHosts(databaseConfig.getHosts());
            }
            int retryTimes = 3;
            boolean success = false;
            for (int i = 0; i < retryTimes; i++) {
                if(!success){
                    FutureTask futureTask = new FutureTask(new Callable() {
                        @Override
                        public Object call() throws Exception {
                            Connection connection = null;
                            try {
                                Class.forName(databaseConfig.getDriver());
                                Properties properties = new Properties();
                                properties.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
                                connection = DriverManager.getConnection(databaseConfig.getDbUrl(),properties);
                            }finally {
                                if(connection != null){
                                    connection.close();
                                }
                            }
                            return connection;
                        };
                    });
                    Thread thread = new Thread(futureTask);
                    thread.start();
                    try {
                        futureTask.get(databaseConfig.getTimeout(), MILLISECONDS);
                        success = true;
                    } catch (TimeoutException e) {
                        success = false;
                        if(i==2){
                          TIException.throwException(e.toString());
                        }
                    }catch (Exception e){
                        TIException.throwException(e.toString());
                    }
                }else {
                    break;
                }
            }
            if(EmptyUtil.isNotEmpty(databaseConfig.getHosts())) DnsCacheManipulatorUtils.removeHosts(databaseConfig.getHosts());
            return ;
        }
        if(databaseConfig.getDriver().equals(EnumDriver.REDIS.getCode())){
            Set<HostAndPort> nodes = new HashSet();
            String url = databaseConfig.getDbUrl();
            String[] array = url.split(",");
            List<String> list = Arrays.asList(array);
            for (int i = 0; i < list.size(); i++) {
                nodes.add(HostAndPort.from(list.get(i)));
            }
            //区分单机和集群
            if(nodes.size() == 1){
                Jedis jedis = null;
                try {
                     jedis = new Jedis(nodes.stream().findFirst().get().getHost(),nodes.stream().findFirst().get().getPort());
                    if(EmptyUtil.isNotEmpty(databaseConfig.getPassword()) && EmptyUtil.isEmpty(databaseConfig.getUsername())){
                        jedis.auth(databaseConfig.getPassword());
                    }
                    if(EmptyUtil.isNotEmpty(databaseConfig.getPassword()) && EmptyUtil.isNotEmpty(databaseConfig.getUsername())){
                        jedis.auth(databaseConfig.getUsername(),databaseConfig.getPassword());
                    }
                    String ping = jedis.ping();
                    if (ping.equalsIgnoreCase("PONG")) {
                        return ;
                    };
                } catch (Exception e) {
                    TIException.throwException(e.getMessage());
                }finally {
                    if(jedis != null){
                        jedis.close();
                    }
                };
            }else{
                JedisCluster cluster = null;
                try {
                    if(EmptyUtil.isNotEmpty(databaseConfig.getPassword()) && EmptyUtil.isEmpty(databaseConfig.getUsername())){
                        cluster = new JedisCluster(nodes, (int)databaseConfig.getTimeout(), (int)databaseConfig.getTimeout(), 3,databaseConfig.getPassword(), new GenericObjectPoolConfig<>());
                    }else if(EmptyUtil.isNotEmpty(databaseConfig.getUsername()) && EmptyUtil.isNotEmpty(databaseConfig.getPassword())){
                        cluster = new JedisCluster(nodes, (int)databaseConfig.getTimeout(), (int)databaseConfig.getTimeout(), 3, databaseConfig.getUsername(),databaseConfig.getPassword(),null,new GenericObjectPoolConfig<>());
                    }else{
                        cluster = new JedisCluster(nodes, (int)databaseConfig.getTimeout(), (int)databaseConfig.getTimeout(), 3, new GenericObjectPoolConfig<>());
                    }
                    cluster.randomKey();
                } catch (Exception e) {
                    TIException.throwException(e.getMessage());
                }finally {
                    if(cluster != null){
                        cluster.close();
                    }
                }
            }
            return;
        }
        DriverManager.getConnection(databaseConfig.getDbUrl(), databaseConfig.getUsername(), databaseConfig.getPassword());
    } catch (Exception e) {
        TIException.throwException(e.getMessage());
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.
Projects
None yet
Development

No branches or pull requests

2 participants