我是初学者,Express.js我对这两个关键词感到困惑:res.end()和res.send().
它们是相同还是不同?
我想通过下面的大文章,了解Twitter的风暴" 了解风暴的拓扑结构的并行 "
但是我对"任务"的概念感到有些困惑.任务是组件的运行实例(spout还是bolt)?具有多个任务的执行程序实际上是说执行程序多次执行相同的组件,我是否正确?
此外,在一般的并行意义上,Storm会为spout或bolt生成一个专用线程(执行程序),但是由具有多个任务的执行程序(线程)对并行性做出了什么贡献?我认为在一个线程中有多个任务,因为一个线程按顺序执行,只会使该线程成为一种"缓存"资源,从而避免为下一个任务运行产生新线程.我对么?
我可以在花更多时间调查之后自己清除那些困惑,但是你知道,我们都喜欢stackoverflow ;-)
提前致谢.
我是Apache POI api的初学者.我正在尝试使用arraylist创建excel表.
我的java代码如下.
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(HSSFColor.LIME.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
HSSFRow row4 = sheet.createRow(4);
row4.createCell(4).setCellValue("name");
row4.createCell(5).setCellValue("emailId");
sheet.autoSizeColumn(5);
List<Bean> nameList = this.getArrayList();
Iterator<Bean> nameListIterator = nameList.iterator();
sheet.autoSizeColumn(5);
int i=5;
HSSFRow row = null;
while(nameListIterator.hasNext())
{
Bean bean = nameListIterator.next();
row = sheet.createRow(i);
row.createCell(4).setCellValue(bean.getName());
row.createCell(5).setCellValue(bean.getMailId());
i++;
}
Run Code Online (Sandbox Code Playgroud)
arraylist如下:
List<Bean> beanList = new ArrayList<Bean>();
beanList.add(new Bean("Amy","g@y.comrtyrtyrtyrtyrtyr"));
beanList.add(new Bean("Joan","p@y.comrtyrtyrtyrtyrtyr"));
beanList.add(new Bean("Megan","r@y.comrtyrtyrtyrtyrtyr"));
beanList.add(new Bean("Joe","m@y.comrtyrtyrtyrtyrtyr"));
beanList.add(new Bean("Febi","j@y.comrtyrtyrtyrtyrtyr"));
Run Code Online (Sandbox Code Playgroud)
生成Excel工作表时,该列不能正确匹配内容的大小.我搜索了谷歌相关的这个问题并找到了
sheet.autoSizeColumn(5);
是我的问题的解决方案.我在上面的代码中添加了,但问题仍然存在.我正确使用它吗?
还有其他解决方案吗?
请帮忙
提前致谢
Ps:我正在使用Apache Poi 3.6
我正在创建一个数据库设置jsf页面,它在页面加载期间显示属性文件的值.然后,用户更新页面并按提交,并在属性文件中更新值.
我遵循了Balusc提供的解决方案
并在辅助bean的构造函数中设置值.
public DbSettingsBean()
{
this.setUserName(helper.getValueForProperty("user_name"));
this.setPassword(helper.getValueForProperty("password"));
}
Run Code Online (Sandbox Code Playgroud)
虽然我设法在页面加载期间显示属性文件中的用户名.我无法在页面加载期间显示inputsecret的密码值.它仍然是空白的.
在页面加载期间是否还有其他方法可以显示密码?
我使用的是JSF RI 1.2和Richfaces 3.3.2
提前致谢
我正在尝试使用站点中的演示代码在数据表中实现延迟加载数据
我收到了错误
javax.el.PropertyNotFoundException: /table.xhtml @14,49 value="#{car.year}": Property 'year' not readable on type java.lang.String
Run Code Online (Sandbox Code Playgroud)
这是我的table.xhtml代码
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:form id="form">
<p:dataTable var="car" value="#{tableBean.lazyModel}" paginator="true" rows="10"
id="carTable" lazy="true">
<p:column headerText="Year" sortBy="year" filterBy="#{car.year}">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Color" sortBy="color" filterBy="#{car.color}">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
TableBean代码
@ManagedBean
public class TableBean {
private LazyDataModel<Car> lazyModel;
private List<Car> cars;
public TableBean() {
System.out.println("Girish");
cars = populateRandomCars(50);
lazyModel = new LazyCarDataModel(cars);
lazyModel.setRowCount(10);
}
public LazyDataModel<Car> getLazyModel() {
return lazyModel;
}
public …Run Code Online (Sandbox Code Playgroud) 我试图将此scriptlet代码转换为JSF类.
视图代码
<f:view>
<h:form binding="#{jsfSocketClient.form}">
<h:outputText binding="#{jsfSocketClient.text}"/>
</h:form>
</f:view>
Run Code Online (Sandbox Code Playgroud)
和java代码
private HtmlForm form = new HtmlForm();
private HtmlOutputText text = new HtmlOutputText();
public HtmlForm getForm()
{
System.out.println("instance: "+FacesContext.getCurrentInstance().getResponseWriter());
ResponseWriter writer = (FacesContext.getCurrentInstance()).getResponseWriter();
try{
int character;
Socket socket = new Socket("127.0.0.1", 8765);
InputStream inSocket = socket.getInputStream();
OutputStream outSocket = socket.getOutputStream();
String str = "Hello!\n";
byte buffer[] = str.getBytes();
outSocket.write(buffer);
char characters = 0;
while ((character = inSocket.read()) != -1) {
text.setValue((char)character);
//writer.write((char)character);
//characters += (char)character;
}
//text.setValue(characters);
if(str.equalsIgnoreCase("bye"))
{ …Run Code Online (Sandbox Code Playgroud) Checkstyle检查注释的长度不超过80个字符.
我如何覆盖此限制并给它另一个值,即140?
我是Java多线程的新手.我正在学习种族条件的概念.
基于Oracle文档
http://docs.oracle.com/javase/tutorial/essential/concurrency/interfere.html
我创建了一个示例代码,如下所示
public class CounterTest {
public static void main(String[] args) {
Thread thread1 = new Thread(new CounterIncThread());
thread1.setName("add thread");
thread1.start();
Thread thread2 = new Thread(new CounterDecThread());
thread2.setName("sub thread");
thread2.start();
Thread thread3 = new Thread(new CounterIncThread());
thread3.setName("add thread2");
thread3.start();
}
}
class CounterIncThread implements Runnable {
public void run() {
SynchronizedCounter counter = new SynchronizedCounter();
counter.increment();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String threadName =
Thread.currentThread().getName();
System.out.println(threadName+ ": "+counter.value());
}
}
class CounterDecThread implements …Run Code Online (Sandbox Code Playgroud) 我尝试在休眠中使用 saveorupdate 方法,结果导致
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'Mobiles' for key 'type_name'
Run Code Online (Sandbox Code Playgroud)
这是我的代码
public ItemType addItemType(String typeName) {
Session session = factory.openSession();
Transaction tx = null;
ItemType itemType = null;
try{
tx = session.beginTransaction();
itemType = new ItemType();
itemType.setTypeName(typeName);
itemType.setDescription("");
itemType.setCreatedBy("shoppingcart");
itemType.setCreatedDate(new Date());
itemType.setUpdatedBy("shoppingcart");
itemType.setUpdatedDate(new Date());
session.saveOrUpdate(itemType);
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace();
}finally {
session.close();
}
return itemType;
}
Run Code Online (Sandbox Code Playgroud)
这是 ItemType 类
@Entity
@Table(name = "item_types")
public class ItemType implements Serializable{
/**
*
*/
private static final long …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Python将Apache Kafka与Apache spark流集成(我是所有这些新手).
为此我完成了以下步骤
bin/kafka-topics.sh --list --zookeeper localhost:2181
https://github.com/apache/spark/blob/master/examples/src/main/python/streaming/kafka_wordcount.py
而代码是
from __future__ import print_function
import sys
from pyspark import SparkContext
from pyspark.streaming import StreamingContext
from pyspark.streaming.kafka import KafkaUtils
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: kafka_wordcount.py <zk> <topic>", file=sys.stderr)
exit(-1)
sc = SparkContext(appName="PythonStreamingKafkaWordCount")
ssc = StreamingContext(sc, 1)
zkQuorum, topic = sys.argv[1:]
kvs = KafkaUtils.createStream(ssc, zkQuorum, "spark-streaming-consumer", {topic: 1})
lines = kvs.map(lambda x: x[1])
counts = lines.flatMap(lambda line: line.split(" ")) \
.map(lambda …Run Code Online (Sandbox Code Playgroud) java ×7
jsf ×3
apache-kafka ×1
apache-poi ×1
apache-spark ×1
apache-storm ×1
checkstyle ×1
database ×1
express ×1
hibernate ×1
jpa ×1
jsf-2 ×1
jsp ×1
node.js ×1
orm ×1
primefaces ×1
python ×1
scriptlet ×1
topology ×1