小编Amb*_*ish的帖子

应用程序到Android中的Viber&Line应用语音通话

最近我正在开发一个应用程序,我必须实现应用程序语音呼叫和即时消息,如Viber和Line.

我做了一些研发,并有两种方法来实现语音通话.

  1. 一个.android.net.sip

    SIP API类和接口

  2. 网络电话

但我很困惑如何使用它.如何在我自己的服务器上为我的应用程序设置SIP服务器,在什么基础上我会打电话给我的朋友,就像我在我的应用程序联系人中有4个朋友.我必须调用第二个,然后我应该通过什么参数来调用他/她啜.

android voip sip

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

Rancher模板 - Hadoop主机名中的非法字符

我们对hadoop + yarn使用rancher模板,但似乎hadoop无法处理使用容器名称作为主机名(例如hadoop_namenode-primary_1).

Caused by: java.net.URISyntaxException: Illegal character in hostname at index 13: http://hadoop_datanode_1:50075/webhdfs/v1/skystore/tmp/devtest_onedir/2016_08_19_02_35_35_32f7/header.json?op=CREATE&user.name=hdfs&namenoderpcaddress=10.42.14.252:8020&overwrite=true
Run Code Online (Sandbox Code Playgroud)

我做错了还是有一些解决方法?

正如我所看到的那样,问题是由于使用容器名称作为主机名而rancher创建带下划线的容器.不知道如何修复它...

java hadoop docker rancher

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

在配置单元中生成星型模式

我来自SQL Datawarehouse世界,从平面Feed我生成维度和事实表.在一般数据仓库项目中,我们将Feed分为事实和维度.例如:

在此输入图像描述

我是Hadoop的新手,我开始知道我可以在hive中构建数据仓库.现在,我熟悉使用guid,我认为它适用于蜂巢中的主键.那么,下面的策略是在hive中加载事实和维度的正确方法?

  1. 将源数据加载到配置单元表中; 比方说Sales_Data_Warehouse
  2. 从sales_data_warehouse生成维度; 例如:

    从Sales_Data_Warehouse中选择New_Guid(),Customer_Name,Customer_Address

  3. 完成所有维度后,再加载事实表

    SELECT New_Guid()AS'Fact_Key',Customer.Customer_Key,Store.Store_Key ... FROM Sales_Data_Warehouse AS'source'JOIN Customer_Dimension Customer on source.Customer_Name = Customer.Customer_Name AND source.Customer_Address = Customer.Customer_Address JOIN Store_Dimension AS'Store' ON Store.Store_Name = Source.Store_Name JOIN Product_Dimension AS'Product'ON .....

这是我应该在hive中加载我的事实和维度表的方式吗?

此外,在一般仓库项目中,我们需要更新维度属性(例如:Customer_Address更改为其他内容)或者必须更新事实表外键(很少,但它确实发生).那么,如何在hive中加载INSERT-UPDATE.(就像我们在SSIS中查找或在TSQL中使用MERGE语句一样)?

hadoop hive data-warehouse dimensional-modeling fact

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

Maven原型:修改artifactId

在进行项目时,我的要求是创建一个模块。

该命令将类似于:

mvn archetype:generate \
  -DarchetypeCatalog=local \
  -DartifactId=test-module
Run Code Online (Sandbox Code Playgroud)

并且目标应该具有以下文件结构

test-module
|--pom.xml
`--src
   `--main
      |--install
      |  `--install.sh
      `--scripts
         `--test_module.sh
Run Code Online (Sandbox Code Playgroud)

我的整个目标是创建另一个从artifactId(例如artifactIdWithUnderscore)派生的变量,-用 underscope替换所有连字符_。这样我就可以使用更新后的变量来创建文件。

例子:

+------------------+---------------------------------+
|INPUT - artifactId|OUTPUT - artifactIdWithUnderscore|
+------------------+---------------------------------+
|    test-module   |          test_module            |
|       temp       |             temp                |
| test-temp-module |       test_temp_module          |
+------------------+---------------------------------+
Run Code Online (Sandbox Code Playgroud)

我尝试通过在archetype-metadata.xml中添加以下条目来创建一个新变量: artifactIdWithUnderscore

选项1:

<requiredProperty key="artifactIdWithUnderscore" >
  <defaultValue>${StringUtils.replace(${artifactId}, "-", "_")}</defaultValue>
</requiredProperty>
Run Code Online (Sandbox Code Playgroud)

输出:

${StringUtils.replace(${artifactId}, "-", "_")}
Run Code Online (Sandbox Code Playgroud)

选项2:

<requiredProperty key="artifactIdWithUnderscore" >
  <defaultValue>${artifactId.replaceAll("-", "_")}</defaultValue>
</requiredProperty>
Run Code Online (Sandbox Code Playgroud)

输出:

maven_archetype_script
Run Code Online (Sandbox Code Playgroud)

上述artifactId的值来自archetype项目本身的POM。

选项 3:

<requiredProperty key="artifactIdWithUnderscore" >
  <defaultValue>${artifactId}.replaceAll("-", …
Run Code Online (Sandbox Code Playgroud)

maven maven-archetype

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

捕获 shell 脚本中函数的退出状态

我有一个非常简单的脚本。

测试文件

_EXECUTE_METHOD () {
  exit 1
}

_EXECUTE_METHOD
ERROR_CODE=$?
if [[ $ERROR_CODE -eq 1 ]]; then
  echo "Got error"
  exit 0
fi
Run Code Online (Sandbox Code Playgroud)

exit 1该脚本在函数内执行时立即终止。我想从函数中捕获此退出状态并在主脚本中处理它。

我已经尝试过set -eset +e但仍然没有成功。我不能使用return声明。

实际输出:

$ sh test.sh 
$ echo $?
1
$
Run Code Online (Sandbox Code Playgroud)

实际输出:

$ sh test.sh
Got error 
$ echo $?
0
$
Run Code Online (Sandbox Code Playgroud)

shell exit

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

Sed和awk导致线环绕

我有一个表格的文件:

FA01_01:The birch canoe slid on the smooth planks  
FA01_02:Glue the sheet to the dark blue background
Run Code Online (Sandbox Code Playgroud)

我需要它的形式(也注意使用小写):

<s> the birch canoe slid on the smooth planks </s> (FA01_01)  
<s> glue the sheet to the dark blue background </s> (FA01_02)
Run Code Online (Sandbox Code Playgroud)

所以我用sed尝试了以下表达式:

sed 's/\(.......\):\(.*$\)/(\1) <s> \2 <\/s>/' tmp.dat
Run Code Online (Sandbox Code Playgroud)

但这是它返回的内容:

</s> (FA01_01)anoe slid on the smooth planks  
</s> (FA01_02)eet to the dark blue background
Run Code Online (Sandbox Code Playgroud)

无论出于何种原因,似乎sed导致被替换的模式环绕到行的开头但仅用于第二个匹配.例:

$> sed 's/\(.......\):\(.*$\)/\1 \2/' tmp.dat
FA01_01 The birch canoe slid on the smooth planks
Run Code Online (Sandbox Code Playgroud)

是的,但是

$>sed 's/\(.......\):\(.*$\)/\2 …
Run Code Online (Sandbox Code Playgroud)

regex unix awk sed

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

android getCacheDir() 处的 NullPointerException

我正在尝试以编程方式清除我的应用程序数据。但我得到了NullPointerEXception以下代码。

这是我的代码:-

public class MyApplication extends Application {
private static MyApplication instance;

@Override
public void onCreate() {
    super.onCreate();
    instance = this;
}

public static MyApplication getInstance(){
    return instance;
}

public void clearApplicationData() {
    File cache = getCacheDir();
    File appDir = new File(cache.getParent());
    if(appDir.exists()){
        String[] children = appDir.list();
        for(String s : children){
            if(!s.equals("lib")){
                deleteDir(new File(appDir, s));
                Log.i("TAG", "**************** File /data/data/APP_PACKAGE/" + s +" DELETED *******************");
            }
        }
    }
}

public static boolean deleteDir(File dir) {
    if (dir != null …
Run Code Online (Sandbox Code Playgroud)

java singleton android nullpointerexception

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

如何使用Java 8编号项?

有一个清单.

List<String> items = new ArrayList<>();
items.add("abcd");
items.add("efgh");
items.add("ijkl");
items.add("mnop");
Run Code Online (Sandbox Code Playgroud)

我想在控制台中打印编号

1. abcd
2. efgh
3. ijkl
4. mnop
Run Code Online (Sandbox Code Playgroud)

我是Java 8的初学者.我正在尝试使用java 8的几个技巧.请帮忙.

java java-8

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

如何将日期添加到配置单元中的数字

我想对日期字段和 int 字段执行加法。

我正在执行以下查询。它抛出错误。我无法添加。这create_date是 DATE 数据类型和durationINT 数据类型。

SELECT (create_date+duration)
FROM course;
Run Code Online (Sandbox Code Playgroud)

请帮我。

谢谢

hive

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

Spring MVC将http params形式化为对象映射成员变量的模型

我努力为这个问题命名.我试图解决的问题与此处描述的问题非常相似,但我没有提交bean的列表,而是提交表示模型对象中的地图的http请求参数,让框架(Spring)负责构建地图来自http请求参数.有人可以建议最好的做法/最干净的方法吗?任何帮助将非常感激.

目前我传递两个String数组,然后在保存到模型对象之前将它们转换为映射.我认为必须有一个更好的方法来做到这一点.

我使用Spring MVC和Freemarker进行视图渲染.

说明代码:

模型对象:

public class Foo {
    private Map<String, String> barMap;
    // other member variables...
}
Run Code Online (Sandbox Code Playgroud)

查看fremarker模板:

<#list foo.barMap?keys as currKey>
    <tr id="barList_${currKey_index}">
        <td><input name="key" type="text" value="${currKey}"/></td>
        <td><input name="value" type="text" value="${foo.barMap[currKey]}"/></td>
    </tr>
</#list>
Run Code Online (Sandbox Code Playgroud)

控制器:

@RequestMapping(value = "/foo", method = RequestMethod.POST)
public String foo (Model model,
                   @RequestParam(value="key", required=false) String[] keys, 
                   @RequestParam(value="value", required=false) String[] values) {

    Foo foo = new Foo();
    Map<String, String> barMap = new HashMap<String, String>();

    if (keys != null && values != null && …
Run Code Online (Sandbox Code Playgroud)

java spring freemarker spring-mvc

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