小编Sye*_*afa的帖子

Datastax Cassandra Driver抛出CodecNotFoundException

确切的例外情况如下

com.datastax.driver.core.exceptions.CodecNotFoundException:找不到请求的操作的编解码器:[varchar < - > java.math.BigDecimal]

这些是我使用Spark 1.5 Datastax-cassandra 3.2.1 CDH 5.5.1的软件版本

我试图执行的代码是使用java api的Spark程序,它基本上从hdfs读取数据(csv)并将其加载到cassandra表中.我正在使用spark-cassandra-connector.最初我有很多关于google s guava库冲突的问题,我可以通过对guava库进行着色并构建一个包含所有依赖项的快照jar来解决这个问题.

但是我能够为某些文件加载​​数据但是对于某些文件我得到了Codec异常.当我研究这个问题时,我在同一个问题上得到了以下线程.

https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/yZyaOQ-wazk

https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/yZyaOQ-wazk

经过这些讨论之后,我理解的是它是我正在使用的cassandra-driver的错误版本.或者仍然存在与番石榴库相关的类路径问题,因为cassandra 3.0及更高版本使用guava 16.0.1,上面的讨论表明类路径中可能存在较低版本的番石榴.

这是pom.xml文件

 <dependencies>
 <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.5.0</version> 
</dependency>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector-java_2.10</artifactId>
<version>1.5.0-M3</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-clientutil</artifactId>
<version>3.2.1</version>
</dependency>

</dependencies>
  <build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                 <filters>
    <filter>
        <artifact>*:*</artifact>
        <excludes>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
            <exclude>META-INF/*.RSA</exclude>
        </excludes>
    </filter>
</filters>
                    <relocations>
                        <relocation>
                            <pattern>com.google</pattern>
                            <shadedPattern>com.pointcross.shaded.google</shadedPattern>
                        </relocation>

                    </relocations>
                    <minimizeJar>false</minimizeJar>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                </configuration>
            </execution>
        </executions> …
Run Code Online (Sandbox Code Playgroud)

guava datastax-java-driver datastax cloudera-cdh spark-cassandra-connector

9
推荐指数
1
解决办法
2万
查看次数

Django-OAuth-ToolKit:使用 OAuth2.0 的客户端凭据授予类型为多个资源/服务生成访问令牌

我有几个后端 API,它们是 Django 项目。他们有一个 UI(单页应用程序)和一个基于用户名密码的登录。

我的客户通常是开发人员,他们不想要 UI,他们想要的只是访问后端 API,他们可以构建自己的仪表板等。他们希望将 API 与后端系统集成。

问题

问题 1. 我打算使用 django-oauth-tool kit ,在我看来,客户端凭据授予类型适合此用例。我对吗 ?

为了进行实验,我在本地运行在 8000 端口上启动了一个单独的 oauth 服务器,我在 8001 上启动了资源服务器 (r1),在 8002 上启动了资源服务器 (r2)。

第1步 :

我去了oauth服务器的管理面板,为资源r1创建了一个用户u1,为资源r2创建了一个用户u2。我去了管理面板中的应用程序模块,在具有授权类型资源所有者密码的应用程序中注册了 r1 和 r2。为了生成访问令牌,我调用了令牌端点

POST -d "grant_type=password&username=u1&password=u1password" -u "clientid of R1:clientsecre of fR1" http://localhost:8000/o/token/
Run Code Online (Sandbox Code Playgroud)

我得到了访问令牌

{"access_token": "KdAOMZBiMomVxpvjAWErwVGog6NRRH", "expires_in": 86400, "token_type": "Bearer", "scope": "read write introspection", "refresh_token": "ffgkZZ5NtVFh4REs0TbFAALNkJqXVQ"}
Run Code Online (Sandbox Code Playgroud)

第2步:

说上面我为资源服务器 R1 生成的访问令牌,所以我去了 R1 的设置文件并添加了这个令牌以进行自省

OAUTH2_PROVIDER = {

'RESOURCE_SERVER_INTROSPECTION_URL': 'http://localhost:8000/o/introspect/',
'RESOURCE_SERVER_AUTH_TOKEN': '9b2uVud7WXHEdyolznvvkM3KwWfkVe',  # OR this but not both:
#'RESOURCE_SERVER_INTROSPECTION_CREDENTIALS': ('5sRVXLoTQj9vlkLWaziIMZrgra1keupWIQ2On2hX','5jwMxls1JiAiQiNVnRTtbjmzgRO20FEHD0BBdiSAwvSL1XswZKqglDRke2L8Ig77ol7OE3ZdsA9SE7sry0u3BXwd1OvfFfhDVJFSLWlPG6g1vB3w4ZFc1g8ZwgzXJooc'),
Run Code Online (Sandbox Code Playgroud)

} …

security django oauth-2.0 django-rest-framework django-oauth

7
推荐指数
1
解决办法
2127
查看次数

cassandra 是否会刷新 nodetool stopdaemon 上的内存表。如果不是,该怎么做才能避免数据丢失

我正在使用apache-cassandra-3.10

我知道优雅地停止 cassandra 的唯一方法是nodetool stopdaemon ,而不是kill -9 pid

但我想知道nodetool stopdaemon在关闭之前是否也将memtables中的数据刷新sstables

如果它不刷新,那么当我使用 nodetool stopdaemon 停止节点时,会导致数据丢失。

在对此进行研究之后,我读到了有关DURABLE_WRITES 的信息。持久写入实际上有什么作用?

此外,datastax 文档在设置 DURABLE_WRITES “不要使用 SimpleStrategy 在键空间上设置此属性”部分下指出

参考: https: //docs.datastax.com/en/cql/3.1/cql/cql_reference/create_keyspace_r.html

如果我的键空间配置为简单策略,我仍然无法从DURABLE_WRITES中受益,以防它有助于解决关机时的数据丢失问题?

在关闭之前手动运行nodetoollush是确保我们在关闭时不会丢失数据的唯一方法吗?

我从https://issues.apache.org/jira/browse/CASSANDRA-3564中了解到,尚未添加关闭时刷新的功能。

另外还有关于同一问题的开放票 https://issues.apache.org/jira/browse/CASSANDRA-12001

目的是避免使用 nodetool stopdaemon 关闭时丢失任何数据。基本上在关闭之前刷新所有表,考虑使用简单策略。

cassandra data-loss nodetool datastax

5
推荐指数
1
解决办法
4856
查看次数

Titan使用Cassandra作为后端:在java中创建,存储和遍历图形

我已经死了泰坦新手,当我开始研究它时,我感到很困惑,因为它有很多新东西,如Gremlin,tinkerpop和rexter等.

我想要的是java中的一个例子,它使用Titan和Cassandra作为后端.我想创建一个图形,存储在cassandra中,检索它并遍历它.一个非常简单的也会很有帮助.

我在java中运行了一个基本的例子.

    BaseConfiguration baseConfiguration = new BaseConfiguration();
    baseConfiguration.setProperty("storage.backend", "cassandra");
    baseConfiguration.setProperty("storage.hostname", "192.168.3.82");

    TitanGraph titanGraph = TitanFactory.open(baseConfiguration);

     Vertex rash = titanGraph.addVertex(null);
        rash.setProperty("userId", 1);
        rash.setProperty("username", "rash");
        rash.setProperty("firstName", "Rahul");
        rash.setProperty("lastName", "Chaudhary");
        rash.setProperty("birthday", 101);

        Vertex honey = titanGraph.addVertex(null);
        honey.setProperty("userId", 2);
        honey.setProperty("username", "honey");
        honey.setProperty("firstName", "Honey");
        honey.setProperty("lastName", "Anant");
        honey.setProperty("birthday", 201);

        Edge frnd = titanGraph.addEdge(null, rash, honey, "FRIEND");
        frnd.setProperty("since", 2011);

        titanGraph.shutdown();
Run Code Online (Sandbox Code Playgroud)

所以当我运行它时,我观察了cassandra日志并创建了一个名为titan的键空间和下表:

  • titan_ids
  • edgestore
  • graphindex
  • 系统属性
  • systemlog
  • txlog
  • edgestore_lock_
  • graphindex_lock_
  • system_properties_lock_

我不知道这些表的用途以及它们如何存储数据.

运行程序后,会创建一个包含2个顶点和它们之间边缘的图形.我查询了表格,并在每个表格中找到了一些十六进制值.

我有以下问题:

  1. 如何将图存储在cassandra中?

  2. 现在我有这个图表说'x'存储在cassandra中.假设我创建了另一个图形'y'并存储它.如何检索和遍历任何特定图表?因为在正常的cql查询中,您知道要查询的表和列.我将如何分别识别'x'和'y'.

  3. 任何人都可以帮助在java中发布示例代码,以使用一些示例csv数据创建图形.存储在Cassandra和一些相同图形的遍历示例.会有很多帮助,因为没有可用的例子是可以理解的.

java cassandra graph-databases graph-traversal titan

1
推荐指数
1
解决办法
295
查看次数